Forum

Thread tagged as: Runway, Shop

Subtotal Error

When displaying the cart this part of the template multiplies the price for some reason

<perch:shop id="total_items_formatted" />

So an item of 50 USD becomes 100 USD at the subtotal of the purchase and then is taxed whatever percentage. What's happening at total_items_formatted? Why does it multiply the price?

Lexi McGee

Lexi McGee 3 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

How many of the item are in the cart?

This sounds like it could be the behaviour I've found, except in my case it's only on products marked with 'use sale price': https://forum.grabaperch.com/forum/05-29-2017-perch-shop-12-cartpricing-mode-issue

Drew McLellan said:

How many of the item are in the cart?

One. Here's a var_dump

Array
(
    [discount_code] => 
    [promotions] => Array
        (
        )

    [product_count] => 1
    [item_count] => 1
    [items] => Array
        (
            [0] => Array
                (
                    [discount] => 0
                    [price_with_tax] => 49.01
                    [price_with_tax_formatted] => $49.01
                    [price_without_tax] => 40.50
                    [price_without_tax_formatted] => $40.50
                    [tax] => 8.51
                    [tax_discount] => 0
                    [tax_formatted] => $8.51
                    [tax_rate] => 21.00
                    [total_tax] => 8.51
                    [total_tax_formatted] => $8.51
                    [total_with_tax] => 49.01
                    [total_with_tax_formatted] => $49.01
                    [total_without_tax] => 40.50
                    [total_without_tax_formatted] => $40.50
                    [ref_sale_prices] => Array
                        (
                            [discount] => 0
                            [price_with_tax] => 49.01
                            [price_with_tax_formatted] => $49.01
                            [price_without_tax] => 40.50
                            [price_without_tax_formatted] => $40.50
                            [tax] => 8.51
                            [tax_discount] => 0
                            [tax_formatted] => $8.51
                            [tax_rate] => 21.00
                            [total_tax] => 8.51
                            [total_tax_formatted] => $8.51
                            [total_with_tax] => 49.01
                            [total_with_tax_formatted] => $49.01
                            [total_without_tax] => 40.50
                            [total_without_tax_formatted] => $40.50
                        )

                    [weight] => 0
                    [sku] => 2253
                    [title] => ADAPTER
                    [Product] => PerchShop_Product Object
                        (
                            [factory_classname:protected] => PerchShop_Products
                            [table:protected] => perch3_shop_products
                            [pk:protected] => productID
                            [index_table:protected] => shop_index
                            [modified_date_column:protected] => productUpdated
                            [deleted_date_column] => productDeleted
                            [duplicate_fields:protected] => Array
                                (
                                    [productStockOnParent] => stock_location
                                    [productSlug] => slug
                                    [productStatus] => status
                                )

                            [exclude_from_api:protected] => Array
                                (
                                    [0] => regular_pricing
                                    [1] => current_price
                                    [2] => productStatus
                                    [3] => productCreated
                                    [4] => productUpdated
                                    [5] => productDeleted
                                    [6] => productTemplate
                                    [7] => productOrder
                                    [8] => stock_location
                                    [9] => productHasVariants
                                    [10] => productStockOnParent
                                    [11] => catalog_only
                                )

                            [event_prefix:protected] => shop.product
                            [pk_is_int:protected] => 1
                            [date_fields:protected] => Array
                                (
                                )

                            [suppress_events] => 
                            [api:protected] => PerchAPI Object
                                (
                                    [app_id] => perch_shop
                                    [nav_app_id] => perch_shop
                                    [version] => 1
                                    [Lang:PerchAPI:private] => PerchAPI_Lang Object
                                        (
                                            [lang_dir] => D:\wamp\www\perch\addons\apps\perch_shop\lang
                                            [lang_file] => D:\wamp\www\perch\addons\apps\perch_shop\lang\en-gb.txt
                                            [lang] => en-gb
                                            [translations:PerchAPI_Lang:private] => 
                                            [to_add:PerchAPI_Lang:private] => Array
                                                (
                                                )

                                        )

                                )

                            [db:protected] => 
                            [details:protected] => Array
                                (
                                    [productID] => 570
                                    [title] => ADAPTER
                                    [sku] => 2253
                                    [productSlug] => 2253-adapter
                                    [stock_level] => 2
                                    [parentID] => 
                                    [productVariantDesc] => 
                                    [productOrder] => 1
                                    [productHasVariants] => 0
                                    [productStockOnParent] => 0
                                    [productDynamicFields] => {"description":{"_flang":"markdown","raw":"","processed":""},"image":{"assetID":"101","title":"Adapter","_default":"\/perch\/resources\/adapter.jpg","bucket":"default","path":"adapter.jpg","size":18520,"w":384,"h":384,"mime":"image\/jpeg","sizes":{"thumb":{"w":"150","h":"150","target_w":150,"target_h":150,"density":2,"path":"adapter-thumb@2x.jpg","size":14440,"mime":"image\/jpeg","assetID":"102"},"w800hc0":{"w":"384","h":"384","target_w":"800","target_h":false,"crop":false,"density":"1","path":"adapter-w800.jpg","size":18520,"mime":"","assetID":"103"},"w80h80c1@1.6x":{"w":80,"h":80,"target_w":"80","target_h":"80","crop":"true","density":"1.6","path":"adapter-w80h80@1.6x.jpg","size":4194,"mime":"image\/jpeg"}}},"slug":"2253-adapter","status":"1","brand":"5","category":null,"catalog_only":"0","price":{"7":"40.5","_default":"40.5"},"sale_price":{"7":"40.5","_default":"40.5"},"trade_price":{"7":"40.5","_default":"40.5"},"on_sale":"1","tax_group":"1","stock_status":"1","stock_location":"0","max_in_cart":null,"requires_shipping":"0","weight":null,"width":null,"height":null,"depth":null}
                                    [productTemplate] => product.html
                                    [productCreated] => 2017-05-30 22:58:44
                                    [productUpdated] => 2017-06-02 15:14:06
                                    [productDeleted] => 
                                    [productStatus] => 1
                                )

                            [optimize_index:protected] => 1
                            [can_log_resources:protected] => 1
                            [prefix_vars] => 1
                        )

                    [qty] => 1
                    [id] => 570
                )

        )

    [shipping_id] => 
    [shipping_method] => 
    [shipping_tax] => 0.00
    [shipping_tax_formatted] => $0.00
    [shipping_tax_rate] => 0
    [shipping_with_tax] => 0.00
    [shipping_with_tax_formatted] => $0.00
    [shipping_without_tax] => 0.00
    [shipping_without_tax_formatted] => $0.00
    [total_items] => 81.00
    [total_items_formatted] => $81.00
    [total_items_tax] => 17.01
    [total_items_tax_formatted] => $17.01
    [total_shipping] => 0.00
    [total_shipping_formatted] => $0.00
    [total_shipping_tax] => 0.00
    [total_shipping_tax_formatted] => $0.00
    [total_items_with_shipping] => 81.00
    [total_items_with_shipping_formatted] => $81.00
    [total_tax] => 17.01
    [total_tax_formatted] => $17.01
    [total_items_discount] => 0.00
    [total_items_discount_formatted] => $0.00
    [total_items_tax_discount] => 0.00
    [total_items_tax_discount_formatted] => $0.00
    [total_items_discounted] => 81.00
    [total_items_discounted_formatted] => $81.00
    [total_items_discounted_with_tax] => 98.01
    [total_items_discounted_with_tax_formatted] => $98.01
    [total_shipping_discount] => 0.00
    [total_shipping_discount_formatted] => $0.00
    [total_shipping_tax_discount] => 0.00
    [total_shipping_tax_discount_formatted] => $0.00
    [total_tax_discount] => 0.00
    [total_tax_discount_formatted] => $0.00
    [total_discounts] => 0.00
    [total_discounts_formatted] => $0.00
    [total_discounts_with_tax] => 0.00
    [total_discounts_with_tax_formatted] => $0.00
    [grand_total] => 98.01
    [grand_total_formatted] => $98.01
    [shipping_weight] => 0.00
    [tax_rate_totals] => Array
        (
            [0] => Array
                (
                    [exchange_rate] => unknown
                    [tax_rate] => 21.00
                    [tax_rate_formatted] => 21 %
                    [total_tax] => 17.01
                    [total_tax_formatted] => $17.01
                    [total_value] => 81.00
                    [total_value_formatted] => $81.00
                    [reporting_tax] => 17.01
                    [reporting_tax_formatted] => $17.01
                    [reporting_value] => 81.00
                    [reporting_value_formatted] => $81.00
                )

        )

    [currency_id] => 7
    [currency_code] => ARS
    [currency_name] => Peso
    [currency_symbol] => $
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

Does it happen if the product is not 'on sale' ?

It does keep happening.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that's curious.

Any way to debug why [total_items] becomes 81.00?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Not for you, no.

Yep, confirmed fixed for me too.