1

関連製品の価格を表示し、関連製品ごとに [カートに追加] ボタンを追加したいと考えています。

以下は、関連製品ページのコード スニペットです。$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 } ?> 
4

3 に答える 3

2

私はここで解決策を見つけました。それは私にとってはうまくいきます: コアファイルを編集する必要はありません

「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>
于 2013-07-28T11:32:35.763 に答える
1

同じ問題がありました。しかし、私は価格だけを表示しなければなりませんでした。したがって、最も速い方法は、customfields.php のsql select ステートメントを変更することです。

Virtuemart 2.0 の Joomla 2.5 のパス administrator/components/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 ?>
于 2012-08-15T15:57:27.747 に答える
0

以下のソリューションの唯一の問題は、関連する製品の正しい画像が表示されないことです。メインの製品画像を使用して、それを繰り返しているだけです。

于 2013-09-29T15:47:50.207 に答える