首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Virtuemart 2/Joomla 2.5.4浏览页面上的Virtuemart Add To Cart按钮

Virtuemart 2/Joomla 2.5.4浏览页面上的Virtuemart Add To Cart按钮
EN

Stack Overflow用户
提问于 2012-05-20 16:50:18
回答 2查看 7.8K关注 0票数 3

我试着找出如何做到这一点,但就是不能解决,我试着在这里,谷歌和通过Virtuemart论坛搜索,但没有成功。

我正在尝试显示“类别”浏览页面上“产品详细信息”页面上的“添加到购物车”按钮。我之前在Virtuemart 1.1中使用以下代码做到了这一点:

代码语言:javascript
复制
<?php echo $form_addtocart ?>

然而,在Virtuemart2中尝试使用相同的代码时,我没有得到任何结果,尽管他们的指南仍然说明了这一点,就我所见:http://virtuemart.net/documentation/Developer_Manual/Modifying_the_Layout.html

我尝试从products页面复制完全相同的代码,但也不起作用,代码是:

代码语言:javascript
复制
<?php
// Add To Cart Button
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {
echo $this->loadTemplate('addtocart');
}  // Add To Cart Button END
?>

我要覆盖的文件位于:

代码语言:javascript
复制
/components/com_virtuemart/views/category/tmpl/default.php (the Category template)
/components/com_virtuemart/views/productdetails/tmpl/default.php (the Product page that the button is from)

=====

如果我忽略了一些简单的东西,或者我遗漏了任何必要的信息,我深表歉意。

你好,阿莱克斯奈尔。

EN

回答 2

Stack Overflow用户

发布于 2012-05-21 01:46:18

对于VM,它可能是一大堆东西。如果您没有调试工具,只需添加以下行,以查看是否满足条件(如Damien所提到的):

代码语言:javascript
复制
echo "vmConfig says: |".VmConfig::get('use_as_catalog', 0)."|";
echo ", Product has prices?: |".$this->product->prices."|";
// Add To Cart Button
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {
    echo $this->loadTemplate('addtocart');
}  // Add To Cart Button END

如果两者都返回为true,那么它就是addtocart按钮的模板。

票数 1
EN

Stack Overflow用户

发布于 2013-01-18 17:52:28

(示例:default_products.php)这将添加“添加到购物车按钮”

代码语言:javascript
复制
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
        <?php // Product custom_fields
        if (!empty($product->customfieldsCart)) {  ?>
        <div class="product-fields">
            <?php foreach ($product->customfieldsCart as $field)
            { ?><div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
                <span class="product-fields-title" ><b><?php echo  JText::_($field->custom_title) ?></b></span>
                <?php echo JHTML::tooltip($field->custom_tip,  JText::_($field->custom_title), 'tooltip.png'); ?>
                <span class="product-field-display"><?php echo $field->display ?></span>

                <span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
                </div><br/ >
                <?php
            }
            ?>
        </div>
        <?php }
         /* Product custom Childs
          * to display a simple link use $field->virtuemart_product_id as link to child product_id
          * custom_value is relation value to child
          */

        if (!empty($this->product->customsChilds)) {  ?>
            <div class="product-fields">
                <?php foreach ($this->product->customsChilds as $field) {  ?>
                    <div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field->field_type ?>">
                    <span class="product-fields-title" ><b><?php echo JText::_($field->field->custom_title) ?></b></span>
                    <span class="product-field-desc"><?php echo JText::_($field->field->custom_value) ?></span>
                    <span class="product-field-display"><?php echo $field->display ?></span>

                    </div><br/ >
                    <?php
                } ?>
            </div>
        <?php } ?>

            <div class="addtocart-bar">

                <?php // Display the quantity box ?>
                <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id;?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
                <span class="quantity-box">
                    <input type="text" class="quantity-input" name="quantity[]" value="1" />
                </span>
                <span class="quantity-controls">
                    <input type="button" class="quantity-controls quantity-plus" />
                    <input type="button" class="quantity-controls quantity-minus" />
                </span>
                <?php // Display the quantity box END ?>

                <?php // Add the button
                $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
                $button_cls = ''; //$button_cls = 'addtocart_button';
                if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
                    $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
                    $button_cls = 'notify-button';
                } ?>

                <?php // Display the add to cart button ?>
                <span class="addtocart-button">
                    <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
                </span>

            <div class="clear"></div>
            </div>

            <?php // Display the add to cart button END ?>
            <input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
            <input type="hidden" name="option" value="com_virtuemart" />
            <input type="hidden" name="view" value="cart" />
            <noscript><input type="hidden" name="task" value="add" /></noscript>
            <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
            <?php /** @todo Handle the manufacturer view */ ?>
            <input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
            <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
    </form>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10672070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档