News:

Support the VirtueMart project and become a member

Main Menu

How to access array node on $cart_prices

Started by GJC Web Design, December 01, 2012, 12:11:33 PM

Previous topic - Next topic

GJC Web Design

Hi,

Hope someone can help me with this..

The array $cart_prices is as follows:

Debug Line 1248 $cart_prices

Array
(
    [basePrice] => 48.7
    [basePriceWithTax] => 50.6
    [discountedPriceWithoutTax] => 0
    [salesPrice] => 50.6
    [taxAmount] => 1.9
    [salesPriceWithDiscount] => 0
    [discountAmount] => 0
    [priceWithoutTax] => 48.7
    [subTotalProducts] => 0
    [4Diff] => 0.194649
    [6] => Array
        (
            [costPrice] => 4.99000
            [basePrice] => 4.866232
            [basePriceVariant] => 4.866232
            [basePriceWithTax] => 5.06
            [discountedPriceWithoutTax] => 0
            [priceBeforeTax] => 4.866232
            [salesPrice] => 5.06
            [taxAmount] => 0.193768
            [salesPriceWithDiscount] => 0
            [salesPriceTemp] => 5.06
            [unitPrice] => 0
            [discountAmount] => 0
            [priceWithoutTax] => 4.866232
            [variantModification] => 0
            [DBTax] => Array
                (
                )

            [Tax] => Array
                (
                    [0] => Array
                        (
                            [0] => Alabama
                            [1] => 4.0000
                            [2] => +%
                            [3] => 1
                            [4] => 47
                            [5] =>
                            [6] => 1
                        )

                )

            [VatTax] => Array
                (
                )

            [DATax] => Array
                (
                )

            [subtotal_with_tax] => 50.6
            [subtotal_tax_amount] => 1.9
            [subtotal_discount] => 0
            [subtotal] => 48.7
        )

    [discountBeforeTaxBill] => 0
    [withTax] => 50.6
    [discountAfterTax] => 50.6
    [shipmentValue] => 11
    [shipmentTax] => 0
    [shipmentTotal] => 0
    [salesPriceShipment] => 0
    [shipment_calc_id] => 0
    [cost] => 0
)


How can I access the node  [6] => Array  as this index is always different in each checkout?
(trying to get the tax rate)

Can't even find where this array is formed - appears in cart.php and vmpsplugin.php

Thanks in advance
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Piero!

As an option:


foreach($cart->products as $productkey => $productvalue) {
        # $cart_prices[$productkey] - this is the node [6] in your example
}


Basically you could get array keys for $cart_prices array from $cart->products array.
Hope this helps.

P.S. Virtuemart management really needs to document their software better  >:(

PRO

what are you trying to do?



$cart_prices['salesPrice']


GJC Web Design

perfect! Thanks Piero!

@Pro - get the taxation percent applied - had been doing by back calculating but with the small amounts rounding errors can be a problem..
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Piero!

No problem GJC Web Design, happy to be helpful  ;)