簡體   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