Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2020
    Location
    Amsterdam
    Posts
    2
    Plugin Contributions
    0

    Default Observer for when the orderstatus is changed in the backend of the webshop

    I was wondering is there is an observer for when the status of an order is changed in the back-admin of the webshop?

    I want to execute a customer function the moment the status of an order is changed to 'delivered' within the backend of the webshop.
    To accomplish that I created an class in the directory ./includes/classes/observers and an autoloader.

    The principal of the observer works when using a total different notifier, but I can't find the correct notifier for changing the orderstatus within the backend of the webshop.
    I tried all the notifiers as descibed in the documentation, but none of them seems to do the job..

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,488
    Plugin Contributions
    88

    Default Re: Observer for when the orderstatus is changed in the backend of the webshop

    Since you're running zc156, yes. The function zen_update_orders_history (present for both the admin and storefront operation) issues the following notification:
    PHP Code:
    $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_STATUS_VALUES', array('orders_id' => $orders_id'new' => $orders_new_status'old' => $orders_current_status)); 
    That function's present in /includes/functions/functions_osh_update.php.

  3. #3
    Join Date
    Apr 2020
    Location
    Amsterdam
    Posts
    2
    Plugin Contributions
    0

    Default Re: Observer for when the orderstatus is changed in the backend of the webshop

    Thanks for the quick reply, but I'am new to ZenCart development and don't know where to put that code.
    I tried to implement your suggestion as follow.
    But when I change the status of an order within the admin nothing happens.


    ./includes/auto_loaders/config.custom_process_status.php

    PHP Code:
    <?php

    if (!defined('IS_ADMIN_FLAG')) {
        die(
    'Illegal Access');
    }
    $autoLoadConfig[190][] = array('autoType'=>'class',
        
    'loadFile'=>'observers/class.custom_process_status.php');
    $autoLoadConfig[190][] = array('autoType'=>'classInstantiate',
        
    'className'=>'custom_process_status',
        
    'objectName'=>'custom_process_status');
    ./includes/classes/obervers/custom_process_status.php

    PHP Code:
    <?php

    class custom_process_status extends base {
        
        function 
    __construct() {
            
    $this->attach($this, array(''ZEN_UPDATE_ORDERS_HISTORY_STATUS_VALUES' ));
        }

        function update($orderid, $new, $old)
        {
            // Do the magic.....
                    echo ' 
    It works';
                    die();

        }
    }

  4. #4
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Observer for when the orderstatus is changed in the backend of the webshop

    Basically for the observer to execute from an admin operation, then something needs to include/require the observer code and then instantiate the observer class... this can be done by loading the catalog side config file from the admin side's same location...

    Note that by the config file being in the catalog side, that it will fire also when/if the notifier is triggered from the catalog side...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Observer for when the orderstatus is changed in the backend of the webshop

    Quote Originally Posted by Ned201 View Post
    The principal of the observer works when using a total different notifier, but I can't find the correct notifier for changing the orderstatus within the backend of the webshop.
    Do I correctly read that to say you HAVE it working with a different Admin-side notifier? Which one? Or only for a Catalog-side notifier? Which one?
    ie: have you put the auto_loaders file on the admin side and got it to load there?
    .

    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.

 

 

Similar Threads

  1. When will there be a fix for the UPS shipping Module
    By MountainWilliam in forum Built-in Shipping and Payment Modules
    Replies: 30
    Last Post: 4 May 2011, 01:51 PM
  2. can the admin create a customer in the backend?
    By cspgsl in forum General Questions
    Replies: 1
    Last Post: 11 Mar 2010, 06:40 AM
  3. Is there any way to make the photos for the items larger?
    By gold in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 11 Dec 2009, 08:19 AM
  4. This is the main define statement for the page for english when no template defined f
    By ginginca in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 10 Nov 2006, 08:15 PM
  5. Is there a shipping method for sending cash though the mail and then i send the good?
    By binny25 in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 9 Nov 2006, 02:18 PM

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