Jump to:

2084 Posts in 1005 Topics by 453 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Add a field to OrderForm

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: 1280 Views
  • meff
    Community Member
    2 Posts

    Add a field to OrderForm Link to this post

    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?

  • TotalNet
    Community Member
    181 Posts

    Re: Add a field to OrderForm Link to this post

    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.



  • meff
    Community Member
    2 Posts

    Re: Add a field to OrderForm Link to this post

    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?

  • neonfrog
    Community Member
    10 Posts

    Re: Add a field to OrderForm Link to this post

    Hi Meff,

    Did you ever get this sorted?

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.