Kryptronic Software Support Forum

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.

#1 09-24-2007 17:55:43

carolsim
Member
Registered: 08-02-2003
Posts: 37

Is there a shipping script that will do this?

Hello: I've looked around on the forum, but I haven't found a script that will do what our client is requesting. She is starting an online book business. Here is her request:



Should I put in an order for a paid modification?


Thanks,

Bob Simpson

Offline

 

#2 09-25-2007 01:46:39

fazman
Member
From: Aus
Registered: 03-19-2006
Posts: 196
Website

Re: Is there a shipping script that will do this?

try this. I have only done the first few. You would need to do this all the way up to 70 for that amount of books. Not sure what you're planning after total of 70 books

<?php

// +--
// | All custom shipping scripts work in the same way.  A global
// | variable named 'ecom.customship' contains the following PHP
// | array.  Array keys with value info:
// |
// | weight     => Total weight of items being shipped.
// | total      => Subtotal of items being shipped.
// | quantity   => Quantity of items being shipped.
// | stateprov  => Ship to state/province.
// | country    => Ship to country.
// | postalcode => Ship to postal code.
// |
// | This script must set a global variable named
// | 'ecom.customship_response' which is an array in the
// | following format:
// |
// | method name => amount
// |
// | NOTE: Do not print anything within custom shipping
// | scripts.  They are designed only to return names and
// | prices for custom shipping methods.
// |
// | This script is a User Defined Calculation script that
// | returns a static method and amount.
// +--

$info = $this->globals('ecom.customship');

$quantity = $info['quantity'];

if ($quantity == '1') {

$custom = array('Shipping' => '3.00');

} elseif ($quantity == '2') {

$custom = array('Shipping' => '3.75');

} elseif ($quantity == '3') {

$custom = array('Shipping' => '4.25');

}


$this->globals('ecom.customship_response',$custom);

?>


has arrived. Flight your way to heavenly pleasures.

Offline

 

#3 09-25-2007 03:05:28

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Is there a shipping script that will do this?

If I'm reading her request correctly she wants to charge an additional 3 dollars when the quantity of books hits 70 and continue to charge 75 cents for additional books beyond that.  This code will only repeat the additional 3 dollars at a quantity of 70.  No need for a big if/then/else statement.

Code:

$ship = 3;

if ($info['quantity'] == 70) {
    $ship += 3;
}

if ($info['quantity'] > 1) {
    $ship += ($info['quantity'] - 1) * .75;
}

$custom = array('Shipping' => $ship);

$this->globals('ecom.customship_response',$custom);

Offline

 

#4 09-28-2007 14:31:57

carolsim
Member
Registered: 08-02-2003
Posts: 37

Re: Is there a shipping script that will do this?

Hello: Thanks for the code, we'll be testing it out soon and let everyone know how it goes.

Bob Simpson

Offline

 

Board footer