簡體   English   中英

ConstanceMart添加到購物車中的其他組件按鈕

[英]virtuemart add to cart button in other component

我為joomla編寫了一個組件,然后將其用於Constancemart Shop組件。 將顯示“添加到購物車”按鈕,它也在那里,但是我不知道我必須包括什么,因為我按了他並且產品在購物車中。

這是另一個組件,我只想在其中包含按鈕。 包含作品,但沒有任何功能。

$this->addtocart($product)

View.html.php

function addtocart ($product) {
        if (!VmConfig::get ('use_as_catalog', 0)) {
            $stockhandle = VmConfig::get ('stockhandle', 'none');
            if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) {
                $button_lbl = vmText::_ ('COM_VIRTUEMART_CART_NOTIFY');
                $button_cls = 'notify-button';
                $button_name = 'notifycustomer';
                ?>
                <div style="display:inline-block;">
            <a href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?>" class="notify"><?php echo vmText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?></a>
                </div>
            <?php
            } else {
                $pr_name = $this->getPrDetails($product->virtuemart_product_id, 'product_name');
                $pr_cat = $this->getCat($product->virtuemart_product_id);
                ?>
            <div class="addtocart-area">

                <form method="post" class="product" action="index.php"> 
                    <div class="addtocart-bar">

                        <?php
                        // Add the button
                        $button_lbl = vmText::_ ('COM_VIRTUEMART_CART_ADD_TO');
                        $button_cls = ''; //$button_cls = 'addtocart_button';


                        ?>
                        <?php // Display the add to cart button ?>
                        <span class="addtocart-button">
                            <?php echo shopFunctionsF::getAddToCartButton(true); ?>
            </span>

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

                    <input type="hidden" class="pname" value="<?php echo $pr_name ?>"/>
                    <input type="hidden" name="option" value="com_virtuemart"/>
                    <input type="hidden" name="view" value="cart"/>
                    <noscript><input type="hidden" name="task" value="add"/></noscript>
                    <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>"/>
                    <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $pr_cat ?>"/>
                </form>
                <div class="clear"></div>
            </div>
            <?php
            }
        }
    }

$ product是表的數組。 按鈕出現了,但是我需要后面的功能。 為此我必須包括什么? 還是行不通?

需要幫助,謝謝。

您顯示的這段代碼是一個addToCart函數,該函數只是為瀏覽器構建標記。 如果您無法將其實際添加到購物車中,請查看此標記的作用...

它構建了一個表單,該表單將多個字段發布到index.html 您需要檢查該POST(單擊“添加到購物車”按鈕時)期間發送的值以及服務器上的相應代碼,以了解為什么未添加產品。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM