by
KK » Fri Nov 21, 2014 4:14 am
Hi lasselupe33,
Apologies again for the delay.
As promised, here is your shipping calculator that uses the
total weight of the cart to get a shipping charge.
I am attaching a modified 'cart_ex.php'. Please extract it and place it within 'couch/addons/cart' folder (replacing the original file of the same name, if it exists).
There are two modifications that you need to do to get things working -
1. Add an editable region to the products template to allow specifying each item's weight.
2. Set the shipping charges scale in the config file.
Here is how you do it -
1. Edit your products template (in our sample it is index.php) and add the definition highlighted below immediately after the 'pp_requires_shipping' field
<cms:editable
name='pp_requires_shipping'
label='Requires shipping'
desc='Select No if this is not a physical product that requires shipping'
opt_values='Yes=1 | No=0'
opt_selected = '1'
type='radio'
group='group_shipping'
order='10'
/>
<cms:editable
name='pp_weight'
label='Weight'
desc='Weight in grams'
maxlength='10'
search_type='decimal'
validator='non_negative_decimal'
width='150'
type='text'
group='group_shipping'
order='10'
/>
Visit the template as super-admin and now you should see a region for specifying weight in the admin.
2. Edit the config file (couch/addons/cart/config.php) and add the code highlighted below just after the 'Ship by quantity ordered' setting.
// Ship by quantity ordered:
// Set the option below if you want to set up a sliding scale of shipping charges based on the number of items in cart.
// For example, if you charge $3 to deliver one to five books, $7 to ship six to 15 books, and $10 to ship more than 15 books,
// set it to '[ 0=3 | 5=7 | 15=10 ]'
// where the string above stands for '3 for more than 0, 7 for more than 5, 10 for more than 15'
$pp['shipping_by_quantity_ordered'] = '';
// Shipping by weight ordered:
// Set the option below if you want to set up a sliding scale of shipping charges based on the order's total weight.
// For example, when the total order weighs between 0-500g the shipping should be 4$, 501-1000g = 7.5$ and finally 1001g+ = 10$
// set it to '[ 0=4 | 500=7.5 | 1000=10 ]'
// where the string above stands for '4 for more than 0, 7.5 for more than 500, 10 for more than 1000'
$pp['shipping_by_weight_ordered'] = '[ 0=4 | 500=7.5 | 1000=10 ]';
/*
Discounts
*/
// Discount by order total:
Add your values to the scale shown in red.
And that should be it.
Any product that has 'required shipping' set to 'Yes', will have its weight taken into consideration while calculating the shipping charges.
Hope this helps.
Please let us know.
Thanks.