Jump to:

2088 Posts in 1007 Topics by 455 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Order Modifiers buggy?

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: 1273 Views
  • dbenton
    Avatar
    Community Member
    22 Posts

    Order Modifiers buggy? Link to this post

    I am trying to get order modifiers working. I wrote a shipping modifier which worked intermittently, and now I cannot get any order modifiers to work.

    Here is my entire test class:

    class TestModifier extends OrderModifier {
       function LiveAmount() {
          return 1;   
       }
       function TableTitle() {
          return 'Test';
       }
    }

    And I've added the following to mysite/_config.php:

    Order::set_modifiers(array('TestModifier'));

    The result is a line item on the checkout page that says "Test" and has a total column value of $0.00 (and the order total is not increased by 1 either).

    Surely I am overlooking something simple.

    Thanks in advance,
    David

  • kcd
    Avatar
    Community Member
    54 Posts

    Re: Order Modifiers buggy? Link to this post

    I found ?flush=1 and dev/build weren't enough to reset the cart so I closed my browser and that worked. Also when you do dev/build check your file is being picked up, mine wasn't when in the mysite directory.

  • dbenton
    Avatar
    Community Member
    22 Posts

    Re: Order Modifiers buggy? Link to this post

    Thanks kcd. I have been (not consistently, but occasionally) deleting my cookies, running /dev/build and flushing the cache, and still the same result.

    What was your solution when the environment builder wasn't including your modifier? Did you just move it to a random folder with a _config.php?

  • dbenton
    Avatar
    Community Member
    22 Posts

    Re: Order Modifiers buggy? Link to this post

    Ok, my modifier class is definitely being included. I see it when I run /dev/build and the line item shows up on the checkout page.

    I just deleted cookies, restarted my browser (why not?) and ran /dev/build. Same result. I don't get it. If this modifier were run at all, it should add $1.00 to the total, correct? How can it be included on the checkout page, but not in the total cost?

    The LiveValue method /is/ being called. For the fun of it, I just added

    echo "Modify!";

    to LiveAmount() and it was echoed three times on the checkout page, but the total was not updated.

    Stumped,
    David

  • kcd
    Avatar
    Community Member
    54 Posts

    Re: Order Modifiers buggy? Link to this post

    Hmmmm, I got it working literally an hour after you first posted.

    I had slightly more code but nothing I thought was critical. I included $is_chargable = false (discount), show in table, show in cart, a cart title... all of which inherit default values.

    I also wrote my onbeforewrite (or whatever it is called) function to save $this=>Amount = $this =>LiveAmount() and another custom variable.

    Unfortunately I don't have my code on me

  • dbenton
    Avatar
    Community Member
    22 Posts

    Re: Order Modifiers buggy? Link to this post

    Thanks for your help, kcd. I've been out of town (left shortly after my first post), and while I was away the client decided to replace the ecommerce module with something a little more mature (but not integrated into SS). I think it was the right decision for this project, but I hope to work with the SS ecommerce module again in the future.

    Best,
    David

  • kcd
    Avatar
    Community Member
    54 Posts

    Re: Order Modifiers buggy? Link to this post

    Understandable, SS ecommerce has been 90% ready for a couple of years now. What did you run with?

  • dbenton
    Avatar
    Community Member
    22 Posts

    Re: Order Modifiers buggy? Link to this post

    We are going to use Avactis (standalone, not hosted). I didn't chose it, but it looks promising. I start on that tomorrow, so we'll see...

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