显示价格并在相关产品中添加到购物车按钮Virtuemart 2.0 [英] Display pricing and add to cart button in related products Virtuemart 2.0

查看:133
本文介绍了显示价格并在相关产品中添加到购物车按钮Virtuemart 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示相关产品的价格,并与每个相关产品一起添加到购物车按钮.

I would like to display the related product pricing and have add to cart button along with each of the related products.

下面是相关产品页面上的代码段. $ field没有可用的定价.如何显示价格和添加到购物车"按钮?预先感谢

Below is the code snippet from the related products page. The $field does not have any pricing available. How can I show the pricing and "add to cart" button? Thanks in advance

<?php
    foreach ($this->product->customfieldsRelatedProducts as $field) {
    ?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
            <span class="product-field-display"><?php echo $field->display ?></span>
            <span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>

        </div>
    <?php } ?> 

推荐答案

我在这里找到了解决方案,它对我有用: 无需编辑核心文件

I have found solution here and it works for me: no need to edit core files

这需要将"default_relatedproducts.php","default_showprices.php"和"default_addtocart.php"复制到您的"template/html/com_virtuemart/productdetails"文件夹中.然后,将"default_relatedproducts.php"中的所有代码替换为以下代码:

It requires copying the "default_relatedproducts.php", "default_showprices.php" and "default_addtocart.php" to your "template/html/com_virtuemart/productdetails" folder. Then replace all of the code in the "default_relatedproducts.php" with the following code:

<?php


// Check to ensure this file is included in Joomla!
defined ( '_JEXEC' ) or die ( 'Restricted access' );
$model = new VirtueMartModelProduct();
$calculator = calculationHelper::getInstance();
$currency = CurrencyDisplay::getInstance();
?>


 <div class="product-related-products">
<h4><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></h4>
<div>
    <?php
    foreach ($this->product->customfieldsRelatedProducts as $field) {
    ?>

<div class="product-field">

<?php
$product = $model->getProductSingle($field->custom_value,true); 
?>

<h2><?php echo JHTML::link ($product->link, $product->product_name); ?></h2>

<a title="<?php echo $product->product_name ?>" rel="vm-additional-images" href="<?php echo $product->link; ?>">
<?php
    echo $this->product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
 </a>


<div class="short_desc"><?php echo $product->product_s_desc; ?></div>

<?php include 'default_showprices.php'; ?>

<?php include 'default_addtocart.php'; ?>
</div>


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

这篇关于显示价格并在相关产品中添加到购物车按钮Virtuemart 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆