| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Add special handling charge to cart totals | ||||
|
|
Thread Tools | Search this Thread |
#21
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Quote:
Thank you Steve I actually followed instructions and got it to work in Gold 4.4.2 but my situation is a bit different. We have extra field that certain products use (extra charge) and so far it works if one product is added to the cart but if you add two or more products it pulls only one extra field value (extra charge). It needs to add this field value for each product in the cart. I played with the code adding foreach ( but no luck. Here is the sample code: PHP Code:
Thanks for your help.
__________________
x-cart 4.4.2 Gold |
|||||||
#22
|
|||||||||
|
|||||||||
Re: Add special handling charge to cart totals
Because your code assigns new value to $handling_special with each loop without adding the old one to the cart. You need to also include in the foreach code to add the value to cart if any then go to the next one. Something like
foreach ($int_hdl as $handling_special) { $handling_special = field_value; cart_total += $handling_special; } } replace cart_total with the actual cart total field (or the field you are adding value to)
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#23
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Quote:
Thank you so much Steve for taking time to look at this, it's a headache. I actually got it to calculate subtotal that includes these extra charges with this code : PHP Code:
but for some reason if I add product that does not have the extra field, it adds extra charge to it as well and than ads discounted total line, subtracts one extra charge. Than at the end shows total plus one extra charge. Seems like the code needs to be somewhere where it calculates $product price, I don't know.
__________________
x-cart 4.4.2 Gold |
|||||||
#24
|
|||||||||
|
|||||||||
Re: Add special handling charge to cart totals
That's way I had the code added inside the foreach loop so it will execute only if the foreach executes - so only if the added product has this extra field value
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#25
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Quote:
Man, it's so close but still adds this charge for all items including item that does not have this extra field. This is the code again (keeping $subtotal inside foreach loop: PHP Code:
This is placed just before the closing bracket of the code: foreach($products as $k=>$product) { - as instructed by the author of this post even tho he states it is in "In Function: func_calculate_shippings" but in xcart 4.4.2 code is a lot different, so maybe this code needs to go in different place?? Or some of the code in other places (as he instructs to put) needs also foreach loop??? I really appreciate all you help Steve.
__________________
x-cart 4.4.2 Gold |
|||||||
#26
|
|||||||||
|
|||||||||
Re: Add special handling charge to cart totals
Then there is soemthign wrong in the above code - you need to debug it and print every value/array to make sure all is adding properly. Could be your sql, could be the foreach you are using
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#27
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Quote:
Hey Steve, I sent you an email this morning "Re: Add special handling charge to cart totals", please take a look when you have a minute. Thanks.
__________________
x-cart 4.4.2 Gold |
|||||||
#28
|
|||||||||
|
|||||||||
Re: Add special handling charge to cart totals
Replied
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#29
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
I just wanted to thank everyone that posted here but mostly Steve as he ended up doing this modification for us and we can't be more happy with his work. Professional, fast and very reasonable rates. I would recommend him to anyone looking for x-cart modification.
Thanks.
__________________
x-cart 4.4.2 Gold |
|||||||
#30
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
I've got this working in my store for good classified as dangerous goods.
We want to add $40 charge including tax. So I have set the value of $handling_special to be 36.36 which is working well, however I also need to know where to put the code to add the 10% tax to this. We offer free freight on all orders over $200 so adding the $handling_special charge to the shipping value is pointless as it gets set back to zero when the order gets over $200. Any help much appreciated.
__________________
X-Cart Gold 4.3.2 (Windows) X-Cart Gold Plus 4.6.1 (Linux) Magic Toolbox slider and zoom |
|||||||
|
|||
X-Cart forums © 2001-2020
|