简体   繁体   English

在美德玛特 3 的产品详细信息页面上的相关产品中添加数量和添加到购物车并以线性方式显示

[英]Adding qty and add-to-cart in related products on product detail page for virtuemart 3 and display in linear fashion

I would like to know how to add qty , add-to-cart button and display them in a linear fashion on the vm3 product details page.我想知道如何在 vm3 产品详细信息页面上添加数量、添加到购物车按钮并以线性方式显示它们。

I located a similar question here ( Display pricing and add to cart button in related products Virtuemart 2.0 ), but none of that works for vm3.我在这里找到了一个类似的问题( 在相关产品 Virtuemart 2.0 中显示定价和添加到购物车按钮),但这些都不适用于 vm3。

I think I found the right files at components/com_virtuemart/sublayouts/related.php but none of the syntax looks like it does in the question I found.我想我在 components/com_virtuemart/sublayouts/related.php 找到了正确的文件,但没有一个语法看起来像我发现的问题。

I will attach a before and after picture of what I'm trying to accomplish.我将附上我正在尝试完成的工作前后的图片。 Before:前:

前

and this is what I would like for it to look like.这就是我希望它的样子。 After:后:

后

If you have any ideas or hints I would be so grateful.如果您有任何想法或提示,我将不胜感激。

This is what I've got in components/com_virtuemart/sublayouts/related.php:这是我在 components/com_virtuemart/sublayouts/related.php 中得到的:

<?php
defined('_JEXEC') or die('Restricted access');

$related = $viewData['related'];
$customfield = $viewData['customfield'];
$thumb = $viewData['thumb'];

//juri::root() For whatever reason, we used this here, maybe it was for the mails
echo JHtml::link (JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $related->virtuemart_product_id . '&virtuemart_category_id=' . $related->virtuemart_category_id), $thumb   . $related->product_name, array('title' => $related->product_name,'target'=>'_blank'));

if($customfield->wPrice){
    $currency = calculationHelper::getInstance()->_currencyDisplay;
    echo $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $related->prices);
}
if($customfield->wDescr){
    echo '<p class="product_s_desc">'.$related->product_s_desc.'</p>';
}

This is what I have in components/com_virtuemart/views/productdetails/tmpl/default.php:这是我在 components/com_virtuemart/views/productdetails/tmpl/default.php 中的内容:

<?php
/**
 *
 * Show the product details page
 *
 * @package VirtueMart
 * @subpackage
 * @author Max Milbers, Eugen Stranz, Max Galt
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default.php 9058 2015-11-10 18:30:54Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

/* Let's see if we found the product */
if (empty($this->product)) {
    echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
    echo '<br /><br />  ' . $this->continue_link_html;
    return;
}

echo shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product));

if(vRequest::getInt('print',false)){ ?>
    <body onload="javascript:print();">
<?php } ?>

<div class="productdetails-view productdetails">
    <?php
    // Product Navigation
    if (VmConfig::get('product_navigation', 1)) {
    ?>
        <div class="product-neighbours">
        <?php
        if (!empty($this->product->neighbours ['previous'][0])) {
            $prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
            echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0]
            ['product_name'], array('rel'=>'prev', 'class' => 'previous-page','data-dynamic-update' => '1'));
        }
        if (!empty($this->product->neighbours ['next'][0])) {
            $next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);
            echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
        }
        ?>
        <div class="clear"></div>
        </div>
    <?php } // Product Navigation END
    ?>

    <?php // Back To Category Button
    if ($this->product->virtuemart_category_id) {
        $catURL =  JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_id, FALSE);
        $categoryName = vmText::_($this->product->category_name) ;
    } else {
        $catURL =  JRoute::_('index.php?option=com_virtuemart');
        $categoryName = vmText::_('COM_VIRTUEMART_SHOP_HOME') ;
    }
    ?>
    <div class="back-to-category">
        <a href="<?php echo $catURL ?>" class="product-details" title="<?php echo $categoryName ?>"><?php echo vmText::sprintf('COM_VIRTUEMART_CATEGORY_BACK_TO',$categoryName) ?></a>
    </div>

    <?php // Product Title   ?>
    <h1 itemprop="name"><?php echo $this->product->product_name ?></h1>
    <?php // Product Title END   ?>

    <?php // afterDisplayTitle Event
    echo $this->product->event->afterDisplayTitle ?>

    <?php
    // Product Edit Link
    echo $this->edit_link;
    // Product Edit Link END
    ?>

    <?php
    // PDF - Print - Email Icon
    if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) {
    ?>
        <div class="icons">
        <?php

        $link = 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->virtuemart_product_id;

        echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_icon', false);
        //echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
        echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon',false,true,false,'class="printModal"');
        $MailLink = 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component';
        echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false,true,false,'class="recommened-to-friend"');
        ?>
        <div class="clear"></div>
        </div>
    <?php } // PDF - Print - Email Icon END
    ?>

    <?php
    // Product Short Description
    if (!empty($this->product->product_s_desc)) {
    ?>
        <div class="product-short-description">
        <?php
        /** @todo Test if content plugins modify the product description */
        echo nl2br($this->product->product_s_desc);
        ?>
        </div>
    <?php
    } // Product Short Description END

    echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop'));
    ?>

    <div class="vm-product-container">
    <div class="vm-product-media-container">
<?php
echo $this->loadTemplate('images');
?>
    </div>

    <div class="vm-product-details-container">
        <div class="spacer-buy-area">

        <?php
        // TODO in Multi-Vendor not needed at the moment and just would lead to confusion
        /* $link = JRoute::_('index2.php?option=com_virtuemart&view=virtuemart&task=vendorinfo&virtuemart_vendor_id='.$this->product->virtuemart_vendor_id);
          $text = vmText::_('COM_VIRTUEMART_VENDOR_FORM_INFO_LBL');
          echo '<span class="bold">'. vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_VENDOR_LBL'). '</span>'; ?><a class="modal" href="<?php echo $link ?>"><?php echo $text ?></a><br />
         */
        ?>

        <?php
        echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>$this->showRating,'product'=>$this->product));

        if (is_array($this->productDisplayShipments)) {
            foreach ($this->productDisplayShipments as $productDisplayShipment) {
            echo $productDisplayShipment . '<br />';
            }
        }
        if (is_array($this->productDisplayPayments)) {
            foreach ($this->productDisplayPayments as $productDisplayPayment) {
            echo $productDisplayPayment . '<br />';
            }
        }

        //In case you are not happy using everywhere the same price display fromat, just create your own layout
        //in override /html/fields and use as first parameter the name of your file
        echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
        ?> <div class="clear"></div><?php
        echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));

        echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));

        // Ask a question about this product
        if (VmConfig::get('ask_question', 0) == 1) {
            $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
            ?>
            <div class="ask-a-question">
                <a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL') ?></a>
            </div>
        <?php
        }
        ?>

        <?php
        // Manufacturer of the Product
        if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
            echo $this->loadTemplate('manufacturer');
        }
        ?>

        </div>
    </div>
    <div class="clear"></div>


    </div>
<?php
    $count_images = count ($this->product->images);
    if ($count_images > 1) {
        echo $this->loadTemplate('images_additional');
    }

    // event onContentBeforeDisplay
    echo $this->product->event->beforeDisplayContent; ?>

    <?php
    //echo ($this->product->product_in_stock - $this->product->product_ordered);
    // Product Description
    if (!empty($this->product->product_desc)) {
        ?>
        <div class="product-description">
    <?php /** @todo Test if content plugins modify the product description */ ?>
        <span class="title"><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE') ?></span>
    <?php echo $this->product->product_desc; ?>
        </div>
    <?php
    } // Product Description END

    echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));

    // Product Packaging
    $product_packaging = '';
    if ($this->product->product_box) {
    ?>
        <div class="product-box">
        <?php
            echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box;
        ?>
        </div>
    <?php } // Product Packaging END ?>

    <?php 
    echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot'));

  echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true ));

    echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories'));

    ?>

<?php // onContentAfterDisplay event
echo $this->product->event->afterDisplayContent;

echo $this->loadTemplate('reviews');

// Show child categories
if (VmConfig::get('showCategory', 1)) {
    echo $this->loadTemplate('showcategory');
}

$j = 'jQuery(document).ready(function($) {
    Virtuemart.product(jQuery("form.product"));

    $("form.js-recalculate").each(function(){
        if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
            var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val();
            Virtuemart.setproducttype($(this),id);

        }
    });
});';
//vmJsApi::addJScript('recalcReady',$j);

/** GALT
 * Notice for Template Developers!
 * Templates must set a Virtuemart.container variable as it takes part in
 * dynamic content update.
 * This variable points to a topmost element that holds other content.
 */
$j = "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';";

vmJsApi::addJScript('ajaxContent',$j);

if(VmConfig::get ('jdynupdate', TRUE)){
    $j = "jQuery(document).ready(function($) {
    Virtuemart.stopVmLoading();
    var msg = '';
    jQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
    jQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});";

    vmJsApi::addJScript('vmPreloader',$j);
}

echo vmJsApi::writeJS();

if ($this->product->prices['salesPrice'] > 0) {
  echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}

?>
</div>

If you are using overrides and you have如果您正在使用覆盖并且您有

/templates/{your_template_folder}/html/com_virtuemart/sublayouts/addtocart.php

than you can use it in specific php overrides, in you specific php override比你可以在特定的 php 覆盖中使用它,在你特定的 php 覆盖中

echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));

On how to use sub layout here official documentation关于如何在此处使用子布局官方文档

And also i think you need to read this one also CODE ADJUSTMENTS FOR VIRTUEMART 3而且我认为你还需要阅读这个VIRTUEMART 3 的代码调整

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

相关问题 在Woocommerce商店页面中更改用于简单产品的购物车按钮 - Change add-to-cart button for simple products in Woocommerce shop page 带有magento附加推车的最新产品 - latest product with add-to-cart in magento 在WooCommerce中添加两个不同的产品和自定义添加到购物车() - Add two different Products with Custom Add-To-Cart() in WooCommerce Virtuemart 2-将产品图片添加到“添加到购物车”弹出窗口 - Virtuemart 2 - Add the product image to the “add to cart”-popup 如何在woocommerce购物车页面中基于当前产品添加相关产品? - How to add related products based on current products in woocommerce cart page? 添加自定义内容特定产品的下一步“添加到购物车”按钮 - Add custom content Next add-to-cart In button for a specific Product 购物车页面中的产品数量下拉菜单-Opencart - Product Qty Dropdown in Cart Page - Opencart 有条件地删除购物车中的按钮并隐藏产品类别的价格 - Conditionally removing add-to-cart button and hiding prices for product categories 在 Woocommerce 单个产品上同步多个 ajax 添加到购物车按钮 - Sync multiple ajax Add-to-cart buttons on Woocommerce single product Woocommerce功能,用于在“ content-product.php”中添加购物车 - Woocommerce function for add-to-cart inside “content-product.php”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM