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

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

问题描述

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

以下是相关产品页面的代码片段.$field 没有任何可用的定价.如何显示定价和添加到购物车"按钮?提前致谢

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>

<?php } ?>

解决方案

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

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

<div class="product-related-products"><h4><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS');?></h4><div><?phpforeach ($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; ?>"><?phpecho $this->product->images[0]->displayMediaThumb('class="browseProductImage"', false);?></a><div class="short_desc"><?php echo $product->product_s_desc;?></div><?php 包含 'default_showprices.php';?><?php 包含 'default_addtocart.php';?>

<?php } ?>

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

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

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天全站免登陆