Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Order class notifiers

    In /includes/classes/order.php the notifiers have been changed from using...
    PHP Code:
    $zco_notifier->notify(); 
    ...to...
    PHP Code:
    $this->notify(); 
    This makes the code look cleaner but doesn't it make the notifiers unusable? My understanding is that to use these notifiers you would now have to attach the observers to the order object. However the order object isn't created until after all the auto-loaders have finished loading.

    Am I missing something? Is there now a way to attach an observer to the order object, or even the order classs?

    Regards,
    Christian.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Order class notifiers

    That's very intentional, as it now makes the notifiers in the order class actually work
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Order class notifiers

    Just to expand on the above.

    When you do something like

    $this->attach($this, array('NOTIFY_ORDER_CART_ADD_PRODUCT_LIST'));

    you are not actually attaching to the class the notifier exists in, you are merely setting a callback to your observer for when that notifier happens.

    It is only when the notifier happens that the class that the notifier exists in is passed to your observer classes update method.

  4. #4
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Re: Order class notifiers

    Hi,

    Thanks for the replies. Sorry if I'm being a bit stupid but I still don't quite understand. I'm used to attaching notifiers like...
    PHP Code:
    $_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END'));
    $zco_notifier->attach($this, array('NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION')); 
    How would I now do a similar thing with the notifiers in the order class code?

    Do I just create my own order object and use that to attach the notifiers?

    Many thanks,
    Christian.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Order class notifiers

    Example:
    In the order class, there's a notifier point NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL.
    So, to hook it, I simply use:
    Code:
        $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Order class notifiers

    You'll use the $this->attach() method to hook notifier points that are inside a class.
    You'll use the $zco_notifier->attach() method to hook notifier points that are NOT inside a class.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Order class notifiers

    Note also,

    Attaching to the cart class is slightly different because of the fact that the instantiated object is stored in the session.

  8. #8
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Re: Order class notifiers

    Quote Originally Posted by DrByte View Post
    You'll use the $this->attach() method to hook notifier points that are inside a class.
    You'll use the $zco_notifier->attach() method to hook notifier points that are NOT inside a class.
    Quote Originally Posted by wilt View Post
    Attaching to the cart class is slightly different because of the fact that the instantiated object is stored in the session.
    Thank you both for your help. I think it was the cart class example that was confusing me. I assumed the other observers had to be attached to specific instantiated objects.

    Many thanks,
    Christian.

 

 

Similar Threads

  1. v151 Shipping Estimator Order Class
    By numinix in forum Bug Reports
    Replies: 2
    Last Post: 8 Jan 2013, 01:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR