News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Adding custom filed to cart checkout session

Started by Priyal, December 01, 2016, 14:52:52 PM

Previous topic - Next topic

Priyal

I've added a custom field over VM checkout . I need that bill amount is saved on selection of this field in orders table . Currently this is the response array before saving cart details to orders table :
Array
(
    [basePrice] => 257
    [basePriceWithTax] => 272.42
    [discountedPriceWithoutTax] => 257
    [salesPrice] => 272.42
    [taxAmount] => 15.42
    [salesPriceWithDiscount] => 0
    [discountAmount] => 0
    [priceWithoutTax] => 257
    [subTotalProducts] => 0
    [billTotal] => 272.42
    [5Diff] => -15.42
   
  • => Array
            (
                [virtuemart_product_price_id] => 86
                [virtuemart_product_id] => 1257
                [virtuemart_shoppergroup_id] => 0
                [product_price] => 257
                [override] => 0
                [product_override_price] => 0
                [product_tax_id] => 0
                [product_discount_id] => 0
                [product_currency] => 144
                [product_price_publish_up] => 0000-00-00 00:00:00
                [product_price_publish_down] => 0000-00-00 00:00:00
                [price_quantity_start] => 0
                [price_quantity_end] => 0
                [created_on] => 2016-08-05 13:06:49
                [created_by] => 814
                [modified_on] => 2016-11-17 10:57:17
                [modified_by] => 814
                [locked_on] => 0000-00-00 00:00:00
                [locked_by] => 0
                [costPrice] => 257
                [basePrice] => 257
                [basePriceVariant] => 257
                [basePriceWithTax] => 272.42
                [discountedPriceWithoutTax] => 257
                [priceBeforeTax] => 257
                [salesPrice] => 272.42
                [taxAmount] => 15.42
                [salesPriceWithDiscount] => 0
                [salesPriceTemp] => 272.42
                [unitPrice] => 0
                [priceWithoutTax] => 257
                [discountAmount] => -0
                [variantModification] => 0
                [DBTax] => Array
                    (
                    )

                [Tax] => Array
                    (
                    )

                [VatTax] => Array
                    (
                        [5] => Array
                            (
                               
  • => Default tax
                                [1] => 6.0000
                                [2] => +%
                                [3] => 0
                                [4] => 47
                                [5] =>
                                [6] => 1
                                [7] => 5
                            )

                    )

                [DATax] => Array
                    (
                    )

                [Marge] => Array
                    (
                    )

                [subtotal_with_tax] => 272.42
            )

        [salesPriceDBT] => Array
            (
            )

        [taxRulesBill] => Array
            (
            )

        [DATaxRulesBill] => Array
            (
            )

        [toTax] => 272.42
        [salesPriceCoupon] => 0
        [withTax] => 272.42
        [shipmentValue] => 0
        [shipmentTax] => 0
        [salesPriceShipment] => 0
        [shipment_calc_id] => 0
        [cost] => 0
        [paymentValue] => 0
        [paymentTax] => 0
        [paymentTotal] => 0
        [salesPricePayment] => 0
        [payment_calc_id] => 0
        [payment_tax_id] => 0
        [payment_value] => 0
        [billSub] => 257
        [billDiscountAmount] => 0
        [billTaxAmount] => 15.42
    )

    Suppose I've selected that custom filed during checkout, then  [billTotal] => 272.42 must change to amount without tax , i.e,  [discountedPriceWithoutTax] => 257

    How this is achieved in VM. Any help is appreciated.

Priyal


jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Priyal

I've added a shopper field (as single checkbox) named Tax Exemption. Whenever a user checks it, tax amount added to product is removed and vice versa. I've used this shopper field id in my script for calculation purposes.
Now , when final checkout is done and cart values are stored in table (order details) , I want that this value is carried to cart session so that on basis of its selection I store the total amount to order table .

I'm using VirtueMart 3.0.18 on Joomla 3.3.6 php 5.4.45

The details which I'm getting in administrator\components\com_virtuemart\models\orders.php is this :
Array
(
    [basePrice] => 257
    [basePriceWithTax] => 272.42
    [discountedPriceWithoutTax] => 257
    [salesPrice] => 272.42
    [taxAmount] => 15.42
    [salesPriceWithDiscount] => 0
    [discountAmount] => 0
    [priceWithoutTax] => 257
    [subTotalProducts] => 0
    [billTotal] => 272.42
    [5Diff] => -15.42
   
=> Array

        (
            [virtuemart_product_price_id] => 86
            [virtuemart_product_id] => 1257
            [virtuemart_shoppergroup_id] => 0
            [product_price] => 257
            [override] => 0
            [product_override_price] => 0
            [product_tax_id] => 0
            [product_discount_id] => 0
            [product_currency] => 144
            [product_price_publish_up] => 0000-00-00 00:00:00
            [product_price_publish_down] => 0000-00-00 00:00:00
            [price_quantity_start] => 0
            [price_quantity_end] => 0
            [created_on] => 2016-08-05 13:06:49
            [created_by] => 814
            [modified_on] => 2016-11-17 10:57:17
            [modified_by] => 814
            [locked_on] => 0000-00-00 00:00:00
            [locked_by] => 0
            [costPrice] => 257
            [basePrice] => 257
            [basePriceVariant] => 257
            [basePriceWithTax] => 272.42
            [discountedPriceWithoutTax] => 257
            [priceBeforeTax] => 257
            [salesPrice] => 272.42
            [taxAmount] => 15.42
            [salesPriceWithDiscount] => 0
            [salesPriceTemp] => 272.42
            [unitPrice] => 0
            [priceWithoutTax] => 257
            [discountAmount] => -0
            [variantModification] => 0
            [DBTax] => Array
                (
                )

            [Tax] => Array
                (
                )

            [VatTax] => Array
                (
                    [5] => Array
                        (
                           
=> Default tax
[1] => 6.0000
                            [2] => +%
                            [3] => 0
                            [4] => 47
                            [5] =>
                            [6] => 1
                            [7] => 5
                        )

                )

            [DATax] => Array
                (
                )

           
[Marge] => Array
                (
                )

            [subtotal_with_tax] => 272.42
        )

    [salesPriceDBT] => Array
        (
        )

    [taxRulesBill] => Array
        (
        )

    [DATaxRulesBill] => Array
        (
        )

    [toTax] => 272.42
    [salesPriceCoupon] => 0
    [withTax] => 272.42
    [shipmentValue] => 0
    [shipmentTax] => 0
    [salesPriceShipment] => 0
    [shipment_calc_id] => 0
    [cost] => 0
    [paymentValue] => 0
    [paymentTax] => 0
    [paymentTotal] => 0
    [salesPricePayment] => 0
    [payment_calc_id] => 0
    [payment_tax_id] => 0
    [payment_value] => 0
    [billSub] => 257
    [billDiscountAmount] => 0
    [billTaxAmount] => 15.42
)

I want that checkbox value included in this array . How this can be achieved ?

Priyal

Hi All,

I really need to do this. Is there anyone who could help me over this?

Thanks In Advance!

Milbo

I think your problem is solved. You should just use what is already there. If not, you need a plugin like avatax. At least 20% of it. Learn our rules system. What you wanna do is very, very tricky. Not by what you want todo, but the effects. You work with internal data without understanding the whole thing. It makes a lot more sense to learn the calculation rules first.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Priyal

Hi Milbo

Thank you for your reply. I'l find about the rules you mentioned.
"Avatax" means Avalara?right? Do I need to register over their website http://www.avalara.com/