Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

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, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Add a field to OrderForm


Go to End


4 Posts   2017 Views

Avatar
meff

Community Member, 2 Posts

2 April 2009 at 1:35am

Hi out there!

I installed the ecommerce-module. Everything is working fine except one thing:
I have to calculate Shipping-Costs by Distance. I use the german PLZ for this calculation which is similar to an american ZIP-Code. Calculating the Distance and the Shipping-Costs is no problem, but i don't know how to add a new Field called 'PLZ' to the Orderform...
Of course there is the $shippingFields-Array, but this is only used if "use different shipping address" is activated...

I tried to solve this by extending member with the DataObjectDecorator. I see the new Field 'PLZ' in the database, but I just don't get it to show a new field in the Checkoutpage...
updateCMSFields didn't wok the way I wanted it to... I created a new Field in the CMS but not in the Checkoutpage.

Anyone out there who can help me?

Avatar
TotalNet

Community Member, 181 Posts

4 April 2009 at 6:50pm

I need to add postcode to the order form as well (also region/state) and can't figure out how to do it either, I'm planning on a workaround that uses the payment method to request the extra fields - not sure if that helps you with shipping calculations though!

If anyone has done this I'd love to learn how too.

Cheers,

Rich

Avatar
meff

Community Member, 2 Posts

8 April 2009 at 2:48am

ok, I solved the problem by adding the PLZ-Field via DataObjectDecorator.
A documentation can be found here: http://doc.silverstripe.org/doku.php?id=dataobjectdecorator
In my case there already was an existing DataObjectDecorator called EcommerceRole which extends the Member-Class by the fields used for ecommerce.

But now there's another problem: How can I calculate the total weight of an order? I tried it this way, but it doesn't seem to work...

//Get the order's Weight
$order = $this->Order();

$orderItems = $order->Items();

// Calculate the total weight of the order
$totalWeight = NULL;

if($orderItems) {
foreach($orderItems as $orderItem) {
$totalWeight = $totalWeight + $orderItem->Weight * $orderItem->quantity;
}

}

Any ideas?

Avatar
neonfrog

Community Member, 10 Posts

8 July 2009 at 2:44pm

Hi Meff,

Did you ever get this sorted?