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.
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.
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;