1998 Posts in 530 Topics by 433 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, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 991 Views |
-
shipping price fixed in admin, but need additional costs for international deleveries

13 January 2011 at 2:44am
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
-
Re: shipping price fixed in admin, but need additional costs for international deleveries

17 January 2011 at 6:28am
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
-
Re: shipping price fixed in admin, but need additional costs for international deleveries

17 January 2011 at 11:22pm
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/1469295I 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 useif($country != "United Kingdom")
It uses the value for "Int_Shipping_Cost" regardless of country selected.Regards
Nels
| 991 Views | ||
|
Page:
1
|
Go to Top |


