| ||||||||||
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 |
#1
|
|||||||
|
|||||||
Add special handling charge to cart totals
Some of the products that our client sells are classified as hazardous materials and so they must be shipped by ground on a special truck. So if a customer adds one or more of these products to their cart, we needed to add an additional flat handling fee of $20 to the shopping cart totals. Regardless of how many of these products are added to the cart, the handling charge would remain $20 per cart. So using the shipping_freight field in the products table would not work since it▓s designed to be incremented each time an additional product is added.
Here▓s the procedure for the solution we came up with: Step 1: Add an extra field: handling_special Default value: (leave blank) Show: Dont check (Doesn▓t really matter, since this is going to be used only in the codework.) Step 2: Create new label: Variable: lbl_handling_special Description: Special Handling Value: Special Handling Step 3: The client wanted to track the special handling cost separate from shipping costs so we created a new field in the ⌠xcart_orders■ table called ⌠handling_special■ using the same definition parameters as the field ⌠shipping_cost■. Later, we▓ll need to modify the INSERT query in func_place_order within func.php to save this new value. Step 4: You will be editing these files: (remember to make backup copies of these files before you make any changes) 1. /include/func.php 2. /skin1/customer/main/cart_totals.tpl 3. /skin1/main/order_info.tpl 4. /skin1/mail/order_data.tpl Edit: /include/func.php In Function: func_calculate_shippings Add this code under other initial definition statements: Code:
In Function: func_calculate_shippings Add this code just before the closing bracket of the code: foreach($products as $k=>$product) { Code:
ALERT: The value ⌠3■ that is hard coded in the query statement above for fieldid is the value that xcart defined for the extra_field when it was created in step 1. You may need to change that value. Look at the xcart_extra_fields table to see what the value is for the extra field you create. In Function: func_calculate_shippings Add this code before: return $return; (this allows the skin1/customer/main/cart_totals.tpl file to retrieve this value.) Code:
In function: func_calculate_single Revise: Code:
Code:
In function: func_calculate_single Add this code after: "shipping_cost"=>price_format($shipping_cost), (This allows skin1/main/order_info.tpl to retrieve the value of the new handling charge.) Code:
In function: func_select_order Add this code just above: return $order; which is located near the end of the function (This allows skin1/main/order_info.tpl to retrieve the value of the new handling charge.) Code:
In function: func_place_order Add: handling_special to the first part of query statement as shown here: Code:
(This will now save the special handling charge in the xcart_orders table along with the other order information.) Code:
Edit: skin1/customer/main/cart_totals.tpl Add the following code wherever you want the special handling charge to be displayed within the cart totals: Code:
Edit: skin1/main/order_info.tpl Add this code after sub total amount: (This will display the new special handling charge when the customer and administrator view the order history.) Code:
Edit: skin1/mail/order_data.tpl Add this code above the line showing shipping cost: (This will show special handling charge in emails that are sent to customer and administrator.) Code:
__________________
X-Cart Gold 4.2.2 - 3.1.19 |
|||||||
|
#2
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Very nice! Exactly what I was looking for.
I modified your scenario to one where the store charges a flat transaction fee per order. Thanks for taking the time to post this. |
|||||||
#3
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
How would you charge a handling fee only if the order total is less than a certain amount?
|
|||||||
#4
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
I don't think you can do what you want in the markup feature under shipping charges. I believe you'd need to modify the code in /include/func.php. Use a conditional statement to check the cart total and if that total is below a specific dollar amount then you'd add the extra handling fee to the total.
Try this... In function: func_calculate_single After this code: $total = $discounted_subtotal + $shipping_cost + $total_tax; Add: Code:
If you need the extra handling fee to show up as a line item in the cart totals for the shopping cart, invoices, order history and confirmation emails, then you'd need to do extra programming similar to my original example. I think I've seen other posts discussing what you want to do so try doing a search. There may be a better way than what I'm suggesting.
__________________
X-Cart Gold 4.2.2 - 3.1.19 |
|||||||
#5
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Has anyone tried this recently? I followed the steps exactly, and my total cost includes the handling, but the handling cost does not show up on the order information. It is like the tpl files are being passed a $handling_special that is NULL, but when I look in the orders table, the correct value is there.
I even tried removing the {if $handling_special ne ""}, but all it showed then was a "$" and no value. It displays when I log into the administrative end to check the order, but does not show up upon checkout or the email invoice. I wonder if some other xcart updates have made this procedure outdated. I did realize that func.php is now split into func.order.php and func.cart.php with their respective functions. Any comments would be greatly appreciated!!!
__________________
Tom Carlson Version 4.1.9 |
|||||||
#6
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Phew! I resolved the issue using the following:
Edit: skin1/customer/main/cart_totals.tpl Add the following code wherever you want the special handling charge to be displayed within the cart totals: Code:
--- ALSO --- Edit: skin1/mail/html/order_data.tpl Add this code above the line showing shipping cost: (This will show special handling charge in emails and invoices that are sent to customer and administrator.) Code:
__________________
Tom Carlson Version 4.1.9 |
|||||||
#7
|
|||||||||
|
|||||||||
Re: Add special handling charge to cart totals
Hmm I wounder if this could be used to add extra charge for different type of payment ways in 4.018?
__________________
----------------------------------- 4.2 rox... http://www.fivestar.nu | www.nystil.se | www.hidealite.se |
|||||||||
#8
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
ok...i was wondering if anyne had an idea to make this work in this scenario. I want to charge a "handling fee" in a way only for international orders. Actually, the fee is for a gov't import certificate that i have to purchase for international orders.
Is there a way to write a conditional statement to check which shipping zone this customer is in before adding this "handling fee"? THanks Otis
__________________
4.5.2 |
|||||||
#9
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Yes, I believe that would be possible. Although I haven't checked it myself, I think the variable for the shipping zone for the customer is "$customer_zone" which you would use in the conditional statement.
if ($customer_zone == 122) $handling_fee = 20.0;
__________________
X-Cart Gold 4.2.2 - 3.1.19 |
|||||||
#10
|
|||||||
|
|||||||
Re: Add special handling charge to cart totals
Any idea how this modification can be used to add a 'handling fee' to certain payment methods?
Thanks!
__________________
X-Cart 4.0.12 Heavy modified with paid, free and forum mods. PHP 5.2.5 | MYSQL 5.0.51a |
|||||||
|
|||
X-Cart forums © 2001-2020
|