You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Pages: 1
This is my code
Calculation On Total Item Cost
<?php
$info = $this->globals('ecom.customship');
$ship_name = 'Standard Shipper';
$ship_total = 0;
if ($info['total'] <= 15) {$ship_total = 7.95;}
elseif ($info['total'] <= 30) {$ship_total = 8.95;}
elseif ($info['total'] <= 50) {$ship_total = 9.95;}
elseif ($info['total'] <= 75) {$ship_total = 10.95;}
elseif ($info['total'] <= 100) {$ship_total = 11.95;}
elseif ($info['total'] <= 125) {$ship_total = 12.95;}
elseif ($info['total'] <= 200) {$ship_total = 14.95;}
else {$ship_total = 16.00;}
if ($info['country'] == 'Canada') {$ship_total = $ship_total + 28.95;}
$canadian_method = 'For Canadian orders of small items (all items must fit within a video box or regular shipping rates apply) please choose this option (no tracking and no insurance)';
$canadian_total = '28.95';
$this->globals('ecom.customship_response',array($ship_name => $ship_total, $canadian_method => $canadian_total));
?>
Item Subtotal $110.49
Delivery Total $20.90
State/Province Tax Total $6.12
Total $137.51
Nebraska order
Shipping should have been 12.95
Item Subtotal $150.60
Delivery Total $22.90
Total $173.50
MN order
Shipping should have been 14.95
SO where might the problem be?
Offline
have you got the product set to the correct shipping method?
Offline
That's what I'm thinking. The products aren't using this method. If they are tied to the proper shipping method, clear your cart and add the items again to rule out cache issues in the cart.
Offline
Yes, and it is not consistent on any product, I have pulled them all and nothing in common
Offline
thank you
Offline
I just looked and do not see it under Store / Component / Settings / Shipping Settings. Did you change it?
Offline
Item Subtotal $57.19
Delivery Total $76.80
Total $133.99
Order Number
ORD2018011610
Order Status
Pending Shipment
3rd one in past 24
Offline
shouldn't it be more like this.
Not sure how you are working canada as you are adding 28.95 to shipping total, but then setting shipping to 28.95 anyway.
<?php $info = $this->globals('ecom.customship'); $ship_name = 'Standard Shipper'; $ship_total = 0; if ($info['total'] >= 0 && $info['total'] <= 15) {$ship_total = 7.95;} elseif ($info['total'] >= 15 && $info['total'] <= 30) {$ship_total = 8.95;} elseif ($info['total'] >= 30 && $info['total'] <= 50) {$ship_total = 9.95;} elseif ($info['total'] >= 50 && $info['total'] <= 75) {$ship_total = 10.95;} elseif ($info['total'] >= 75 && $info['total'] <= 100) {$ship_total = 11.95;} elseif ($info['total'] >= 100 && $info['total'] <= 125) {$ship_total = 12.95;} elseif ($info['total'] >= 125 && $info['total'] <= 200) {$ship_total = 14.95;} else {$ship_total = 16.00;} $custom = array('Standard Shipper' => $ship_total); if ($info['country'] == 'Canada') { $ship_total = $ship_total + 28.95; $canadian_method = 'For Canadian orders of small items (all items must fit within a video box or regular shipping rates apply) please choose this option (no tracking and no insurance)'; $custom = array($canadian_method => $ship_total); } $this->globals('ecom.customship_response',$custom); ?>
Last edited by zanart (01-17-2018 03:08:46)
Offline
@zanart: That logic is off. If on one condition you use 'less than or equal to X', in the next line you should use 'greater than X', not 'greater than or equal to X' as that's a condition that matches the previous one partially. The if-elseif-else condition in post 1 is accurate and would work as intended.
Offline
here's the default(written by you) custom method based on cost
$info = $this->globals('ecom.customship'); $method = 'Standard Carrier'; if ($info['total'] >= '0' && $info['total'] <= '9.99') { $custom = array($method => '2.50'); } elseif ($info['total'] > '9.99' && $info['total'] <= '15.99') { $custom = array($method => '3.95'); } elseif ($info['total'] > '15.99' && $info['total'] <= '49.99') { $custom = array($method => '5.00'); } else { $custom = array($method => '0.00'); } // End of if statement. $this->globals('ecom.customship_response',$custom);
Looks similar to the logic in my version??
Anyway, is the problem down to $this->globals('ecom.customship_response',$custom);in the original script,
can you use:
$this->globals('ecom.customship_response',array($ship_name => $ship_total, $canadian_method => $canadian_total));
Offline
so what do I need to do, this script worked all day long on 7, I am getting shipping errors everyday & losing orders!
Offline
zanart wrote:
here's the default(written by you) custom method based on cost
Yours reads on one line less than or equal to X, then on the next greater than or equal to X.
Mine reads on one line less than or equal to X, then on the next greater than X.
Offline
It's actually $7.95 being added, which leads me to believe that you are rating two different shipping groups. Check all your items to be sure that all of them have the same shipmethod (custom), custom script (whatever this script is) and same ship from location (country, state, zip). You are probably seeing two groups of items being rated in checkout and if you duplicated a problem order could probably verify that.
Offline
Pages: 1