my client only ships within South Africa and have two flat rate costs R35 or R60.
For orders where all the products are of type 'Flowers' the R35 rate applies. For an order that includes any other product type the R60 rate applies.
How do I go about setting up this calculation? I guess that I need to create a custom php script. Looking at the supplied scripts for FedEx and UPS I can sort of see how to do it. Do you have any kind of guide or API spec to help me? How do I iterate over the cart contents and check the product types? What variables need to be set by the script for the shipping cost to be added to the order and shown on the checkout confirmation page?
Roger (Guest)
19 Jun 2007 11:18 AM
OK. I worked it out for myself. Here's the code.
<?php
/* Default charge is that for flowers only.
* If there is any item in the shopping cart that is not of
* type flowers then the standard rate aplies.
*/
$shipping_charge = $module_params['Delivery_Charge_Flowers_Only'];
foreach ($shopping_cart as $cart_item) {
if ($cart_item['ITEM_TYPE_ID'] != '3') {
$shipping_charge = $module_params['Delivery_Charge_Standard'];
break;
}
}
Sorry about the formating. Forum does not seem to allow any formatting, it even removes white space at start of lines.
strophy
3 Sep 2007 11:31 PM
Hi,
thanks for the code. As a less experienced programmer, I would really appreciate if anyone could document what the contents of the $shipping_types array mean, and how to reference such a file so that it is used by my custom shipping module. I guess it is using the 'Is External' setting, right?
Thanks for any help
Leon
benshanks
22 Jan 2009 6:12 PM
Has anyone managed to set custom shipping rates using external PHP code, have tried but no joy yet
Anyone ?
foxtrotdomains.com
22 Jan 2009 6:40 PM
I am trying with a few others to request a custom shipping module from ViArt, read the Customization Forum.
If you are interested Ben, please let us know on that forum.