繁体   English   中英

显示相关产品Virtuemart 2.0中的定价和添加到购物车按钮

[英]Display pricing and add to cart button in related products Virtuemart 2.0

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

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

<?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 } ?> 

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

它需要将“default_relatedproducts.php”,“default_showprices.php”和“default_addtocart.php”复制到“template / html / com_virtuemart / productdetails”文件夹中。 然后使用以下代码替换“default_relatedproducts.php”中的所有代码:

<?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>

有同样的问题。 但我必须只显示价格。 所以最快的方法是在customfields.php中更改sql select语句

路径Joomla 2.5 for Virtuemart 2.0管理员/组件/ com_virtuemart / models / customfields.php第548行

public function getProductCustomsFieldRelatedProducts($product)

只改变

$query=

'SELECT C.`virtuemart_custom_id` , `custom_parent_id` , `admin_only` , `custom_title` , `custom_tip` , C.`custom_value` 
AS value, `custom_field_desc` , `field_type` , `is_list` , `is_hidden` , C.`published` , field.`virtuemart_customfield_id` , 
    field.`custom_value`, field.`custom_param`, price.`product_price`, field.`ordering`
        FROM `#__virtuemart_customs` AS C
        LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
        LEFT JOIN `#__virtuemart_product_prices` AS price ON 
    field.`custom_value` = price.`virtuemart_product_id`
        Where field.`virtuemart_product_id` ='.(int)$product->virtuemart_product_id.' and `field_type` = "R"';

毕竟在线559改变了

$field->custom_price

$field->product_price

最后......在产品描述的模板视图中插入以下代码以显示相关产品的价格

<?php echo $field->product_price ?>

以下解决方案的唯一问题是它不会显示相关产品的正确图像。 它使用主要产品图像,只是重复它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM