2 Replies - 618 Views - Last Post: 19 September 2012 - 09:19 AM Rate Topic: -----

#1 iheartbreakz  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 196
  • Joined: 27-April 11

shipping cost calculation

Posted 18 September 2012 - 10:00 PM

I am trying to make it so that if you choose more than 3 files the shipping cost returns as zero.. and if it is less than 3 then the shipping cost should be a $1.00 in total (0.50+0.50 function i have below). The problem is sometimes it shows 0.00$ as the shipping cost.. something it shows 1.50$ as the shipping cost which is impossible.. I need to know how to make it a fixed shipping cost so if its less than 3 it should be a 1.00$ otherwise $0.00 if its more than 3

Here's my code:
Display part:
 if ($isCheckout !== true) {
         // IF THIS IS THE CHECKOUT, HIDE THE SHIPPING BUTTONS 
             echo "<p class='red'><strong>Select delivery destination</strong></p><p><input type='radio' id='uk' name='shipping' value='1'";
               if ($this->shippingarea == 1) {echo " checked='checked'";}   // makes checkbox 'sticky'
            echo " />&nbsp;United Kingdom\n";                          // United Kingdom
            echo "<input type='radio' id='europe' name='shipping' value='2'";
                 if ($this->shippingarea == 2){echo " checked='checked'";}    // Europe
            echo " />&nbsp;Europe\n";
            echo "<input type='radio' id='world' name='shipping' value='3'";
               if ($this->shippingarea == 3){echo " checked='checked'";}    // International
            echo " />&nbsp;International</p>\n";


Code for calculation(which i think has something wrong to it:
		// If any items in the cart
		if($this->itemCount > 0)
		    {
                switch ($this->shippingarea)
                {
                case 1:     
                if ($this->itemCount < 3){$this->shippingfee = ($this->itemCount * 0.50) + 0.50;}
                else
                {$this->shippingfee = 0;}
                break;
                case 2:
                $this->shippingfee = ($this->itemCount * 0.50) + 0.50;
                break;
                case 3:
                $this->shippingfee = ($this->itemCount * 0.50) + 0.50;
                }


Checkout page where it is calculated:
 if ($isCheckout === true) {
         echo "\t\t\t\t\t\t<span id='jcart-subtotal'>" . $text['shipping_name'] . ": <strong>" . $text['currency_symbol']  . number_format($this->shippingfee,2) . "</strong></span>\n";

This post has been edited by iheartbreakz: 18 September 2012 - 10:03 PM


Is This A Good Question/Topic? 0
  • +

Replies To: shipping cost calculation

#2 Slice  Icon User is offline

  • sudo pacman -S moneyz


Reputation: 242
  • View blog
  • Posts: 706
  • Joined: 24-November 08

Re: shipping cost calculation

Posted 19 September 2012 - 02:46 AM

It says $1.50 because if the customer orders two products the calculation is
(2 * 50) + 50

which is correct at $1.50

What's wrong with just putting $1.00 if you want to keep it at a constant?
if ($this->itemCount < 3){$this->shippingfee = 1.00;}


This post has been edited by Slice: 19 September 2012 - 02:46 AM

Was This Post Helpful? 1
  • +
  • -

#3 iheartbreakz  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 196
  • Joined: 27-April 11

Re: shipping cost calculation

Posted 19 September 2012 - 09:19 AM

changed it to
if($this->itemCount > 0)
		    {
                switch ($this->shippingarea)
                {
                case 1:     
                if ($this->itemCount < 3){$this->shippingfee = 1.00;}
                else
                {$this->shippingfee = 0;}
                break;
                case 2:
                $this->shippingfee = 1.00;
                break;
                case 3:
                $this->shippingfee = 1.00;
                }


now the problem is that the shipping cost after I choose more than 3 items the shipping cost sometimes shows up as 0.00$ and sometimes doesn't.. i wanna make that only for case 1 though
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1