Forum

Thread tagged as: Shop

Shop Cart API for postage & discount

Hi

I want to display postage & discount using API calls. like perch_shop_cart_total()

but I can seem to find any to print out the postage and discount amounts.

please help

tony

Tony Monckton

Tony Monckton 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You should be able to get everything from perch_shop_cart() using the skip-template option.

Cool!!!!

many thanks

tony

Hi,

Also, is there a way to get all the cart contents, including items/products in the cart?

tony

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, using the same.

ok, cool.

I need help with cart.html perch don't parse it ok. Ive checked it over and over again...

the output I get is.. Qty: [ input box ] " value="" type="number" min="0" />

code;

perch_shop_cart(['template' => 'cart/cart.html']);

cart.html

<perch:form id="cart" app="perch_shop" class="cart">
    <div ID="10" class="cart-header">
        <div class="close1" data-id="10"></div>
        <div class="cart-sec simpleCart_shelfItem">
            <div class="cart-item cyc">
                <perch:cartitem id="image" type="image" width="80" height="80" density="1.6" crop="true" output="tag" />
            </div>
            <div class="cart-item-info">
                    <h3><perch:cartitem id="title" /></h3>
                    <p><perch:cartitem id="variant_desc" /></p>
                    <br>
                    <ul class="qty">
                        <li>
                            <p>Qty: 
                                <perch:input id="qty:<perch:cartitem id="identifier" />" value="<perch:cartitem id="quantity" />" type="number" min="0" />
                            </p>
                        </li>
                        <li>
                            <perch:if exists="on_sale">
                                <perch:cartitem id="sale_price" type="shop_currency_value" label="Price" size="m" min="0" step="any" />
                                <p>Sale price! Usually
                                    <perch:cartitem id="price" type="shop_currency_value" label="Price" size="m" min="0" step="any" />
                                </p>
                            <perch:else />
                                <p>Price: </p>
                                <perch:cartitem id="price" type="shop_currency_value" label="Price" size="m" min="0" step="any" />
                            </perch:if>
                        </li>
                    </ul>

            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</perch:form>

thanks in advance

tony

Drew McLellan

Drew McLellan 2638 points
Perch Support

What have you tried to resolve it?

with debug on...

Debug Message

[1] SELECT * FROM perch2_pages WHERE pagePath='/checkout.php' LIMIT 1 [1] SELECT * FROM perch2_shop_cart WHERE cartID=152 [1] SELECT * FROM perch2_shop_cart WHERE cartID=152 [31] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0 [1] SELECT itemID, itemQty FROM perch2_shop_cart_items WHERE cartID=152 AND productID=0 [1] SELECT * FROM perch2_shop_products WHERE productID=0 AND productDeleted IS NULL LIMIT 1 Limiting based on stock. ------------------------------ Calculating cart ------------------------------ [1] SELECT * FROM perch2_shop_cart WHERE cartID=152 [1] SELECT * FROM perch2_shop_cart WHERE cartID=152 [1] SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1 [1] SELECT locationID FROM perch2_shop_tax_locations WHERE locationIsHome=1 LIMIT 1 [1] SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1 [1] SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1 [1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM perch2_shop_cart_items WHERE cartID=152 Tax mode: exc [1] SELECT * FROM perch2_shop_cart_items WHERE cartID=152 ORDER BY itemID ASC [1] SELECT * FROM perch2_shop_products WHERE productID=10 AND productDeleted IS NULL LIMIT 1 [1] SELECT * FROM perch2_shop_tax_groups WHERE groupID=1 AND groupDeleted IS NULL LIMIT 1 [0] SELECT r.rateValue FROM perch2_shop_tax_group_rates gr, perch2_shop_tax_rates r WHERE gr.rateID=r.rateID AND gr.groupID=1 AND gr.locationID=1 [nil] SELECT * FROM perch2_shop_promotions WHERE promoFrom<='2016-07-25 07:32:00' AND promoTo>'2016-07-25 07:32:00' AND promoActive=1 AND promoDeleted IS NULL ORDER BY promoOrder ASC UPDATE perch2_shop_cart SET cartTotalItems='4', cartTotalProducts='1', cartTotalWithTax='79.96', cartTotalWithoutTax='79.96' WHERE cartID='152' INSERT INTO perch2_shop_cart_data(cartID,productID,cartData) VALUES('152',NULL,'{\"productID\":\"10\"}') [1] SELECT itemID, itemQty FROM perch2_shop_cart_items WHERE cartID=152 AND productID=10 [1] SELECT * FROM perch2_shop_products WHERE productID=10 AND productDeleted IS NULL LIMIT 1 Limiting based on stock. UPDATE perch2_shop_cart_items SET itemQty=4 WHERE itemID=11 ------------------------------ Calculating cart ------------------------------ [1] SELECT * FROM perch2_shop_cart WHERE cartID=152 [1] SELECT * FROM perch2_shop_cart WHERE cartID=152 [1] SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1 [1] SELECT locationID FROM perch2_shop_tax_locations WHERE locationIsHome=1 LIMIT 1 [1] SELECT * FROM perch2_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1 [1] SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1 [1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM perch2_shop_cart_items WHERE cartID=152 Tax mode: exc [1] SELECT * FROM perch2_shop_cart_items WHERE cartID=152 ORDER BY itemID ASC [1] SELECT * FROM perch2_shop_products WHERE productID=10 AND productDeleted IS NULL LIMIT 1 [1] SELECT * FROM perch2_shop_tax_groups WHERE groupID=1 AND groupDeleted IS NULL LIMIT 1 [0] SELECT r.rateValue FROM perch2_shop_tax_group_rates gr, perch2_shop_tax_rates r WHERE gr.rateID=r.rateID AND gr.groupID=1 AND gr.locationID=1 [nil] SELECT * FROM perch2_shop_promotions WHERE promoFrom<='2016-07-25 07:32:00' AND promoTo>'2016-07-25 07:32:00' AND promoActive=1 AND promoDeleted IS NULL ORDER BY promoOrder ASC UPDATE perch2_shop_cart SET cartTotalItems='4', cartTotalProducts='1', cartTotalWithTax='79.96', cartTotalWithoutTax='79.96' WHERE cartID='152'

also html produced is below

it not working :(

tony

<div id="10" class="cart-header">
        <div class="close1" data-id="10"></div>
        <div class="cart-sec simpleCart_shelfItem">
            <div class="cart-item cyc">
                <perch:cartitem id="image" type="image" width="80" height="80" density="1.6" crop="true" output="tag">
            </perch:cartitem></div>
            <div class="cart-item-info">
                    <h3><perch:cartitem id="title"></perch:cartitem></h3>
                    <p><perch:cartitem id="variant_desc"></perch:cartitem></p>
                    <br>
                    <ul class="qty">
                        <li>
                            <p>Qty: 

                            </p>
                        </li>
                        <li>

                                <p>Price: </p>
                                <perch:cartitem id="price" type="shop_currency_value" label="Price" size="m" min="0" step="any">

                        </perch:cartitem></li>
                    </ul>

            </div>
            <div class="clearfix"></div>
        </div>
    </div>

this seems to be parsed, as the perch:input is not in the html

<p>Qty: <perch:input id="qty:<perch:cartitem id="identifier" />" value="<perch:cartitem id="quantity" />" type="number" min="0" /> </p>

Drew McLellan

Drew McLellan 2638 points
Perch Support

What HTML output do you get?

Hi Drew,

I was using the example perchdemo-nest cart.html

I just copy cart.html from perch/apps/shop/template/cart and that works ok. so I will modify that.

tony

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, great.