Jump to:

2082 Posts in 1002 Topics by 452 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » shipping price fixed in admin, but need additional costs for international deleveries

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1145 Views
  • neilos
    Avatar
    Community Member
    19 Posts

    shipping price fixed in admin, but need additional costs for international deleveries Link to this post

    Hi all,

    I have SS 2.3.5 with the ecommerce module on.
    The module is heavily customised so upgrading will be extremly time consuming.

    What I have is, in the admin section there is a shipping costs field where the admin can assign different costs for shipping on a product by product basis.
    I have added an extra field for the international costs but can't implement it to work as required.

    The code i have from code > products > Product.php;

    function UnitShipping_Cost() {

    global $country;

    if ($country == "GB" )
    {
    if ($this->Product()->Shipping_Cost) return $this->Product()->Shipping_Cost;
    }
    else
    {
    if ($this->Product()->Int_Shipping_Cost) return $this->Product()->Int_Shipping_Cost;
    }

    }

    Currently what happens is the $country is being ignored and the international shipping rate is being applied.
    How do I find the $country first to add teh relevant shipping amount?

    Hanx in advance

    Nels

  • patjnr
    Avatar
    Community Member
    101 Posts

    Re: shipping price fixed in admin, but need additional costs for international deleveries Link to this post

    Hi Neilos

    With e-commerce you can get every logged in member country as this is also used on billing address.
    The simplest way of getting user's Country is by using EcommerceRole::findCountry() aslo with your UnitShipping_Cost method, if this condition is not met ($country == "GB" ), then nothing was happening.

       function UnitShipping_Cost() {
          $country = EcommerceRole::findCountry();
          if($country == "United Kingdom"){
             return ($this->Product()->Shipping_Cost) ? $this->Product()->Shipping_Cost : $this->Product()->Int_Shipping_Cost;
          }
          return $this->Product()->Int_Shipping_Cost;
       }   

    Can you post you Product.php as your modifications might help many people.

    thx

    PJ

  • neilos
    Avatar
    Community Member
    19 Posts

    Re: shipping price fixed in admin, but need additional costs for international deleveries Link to this post

    Hi PAt Jnr,

    Thanks for looking at this.
    You can view all of Product.php here, I hope someone else finds it useful:
    http://pastie.org/1469295

    I have added your function, but it still doesn't alter the shipping costs at checkout for UK or non-UK orders.

    FYI;

    In that function, if I use

    if($country == "United Kingdom")


    It uses the value for "Shipping_Cost" regardless of country selected
    And if I use

    if($country != "United Kingdom")


    It uses the value for "Int_Shipping_Cost" regardless of country selected.

    Regards

    Nels

    1145 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.