Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 38
  1. #21
    Join Date
    Apr 2007
    Location
    Los Angeles, CA
    Posts
    45
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by DrByte View Post
    Try using this:
    Code:
     $_SESSION['cart']->weight
    $_SESSION['cart']->weight returns what's same as $total_weight.
    Below (within the notifier class' function update), derived from class shipping did the job calculating proper [actual] shipping weight.

    Code:
       function update(&$callingClass, $eventID) { 
           if (!$this->xml_config_switch()) return;
           global $order, $insert_id;
        //Begin Shipping Weight Calculation
        $shipping_weight = $order->total_weight;
        $za_tare_array = split("[:,]" , SHIPPING_BOX_WEIGHT);
           $zc_tare_percent= $za_tare_array[0];
           $zc_tare_weight= $za_tare_array[1];
           $za_large_array = split("[:,]" , SHIPPING_BOX_PADDING);
           $zc_large_percent= $za_large_array[0];
           $zc_large_weight= $za_large_array[1];
        switch (true) {
            // large box add padding
            case(SHIPPING_MAX_WEIGHT <= $shipping_weight):
            $shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight;
            break;
            default:
            // add tare weight < large
            $shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight;
            break;
          } //End Shipping Weight Calculation

  2. #22
    Join Date
    Jul 2008
    Location
    Bald Knob, AR
    Posts
    18
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    I was wondering if anyone has gone any further with this? Such as integrating in with the admin? If not, I guess I'll just have to do it myself.

    Has anyone got this to work on a production site?
    My Zen Cart Store: Outdoor Survival Gear Shop

  3. #23
    Join Date
    Jul 2008
    Location
    Bald Knob, AR
    Posts
    18
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    I've nearly got that XML generation integrated, but I'm running into one little problem.

    I can write a properly formatted XML file for a particular order, and even write it to a file on my server. How do I then get that file down to the local system which is where Dazzle apparently checks for XML files?

    What I am trying to do is create an automated system, where the admin will just click a button on the order page and an Endicia label will print.

    Any ideas?
    My Zen Cart Store: Outdoor Survival Gear Shop

  4. #24
    Join Date
    Apr 2007
    Location
    Los Angeles, CA
    Posts
    45
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by chaoscube View Post
    I've nearly got that XML generation integrated, but I'm running into one little problem.

    I can write a properly formatted XML file for a particular order, and even write it to a file on my server. How do I then get that file down to the local system which is where Dazzle apparently checks for XML files?

    What I am trying to do is create an automated system, where the admin will just click a button on the order page and an Endicia label will print.

    Any ideas?
    Set up an FTP server on your server and use something like NetworkAutomation's Automate, or even a regular FTP clients (not all of them does the job, but some do have scheduling capabilities) to schedule download every .xml files to Dazzle folder.

    I'm using Automate 6.2, which is a great programming tool that costs little less than $1,000 to do lots of other things, too, in addition to a simple scheduled downloading task I mentioned above.

    But all you need is schedule download using a regular FTP client.

    Or compose a batch file that would authenticate, get all files from a specific location, delete from the original location, and schedule it using the windows' Schedule Task found under Control Panel.

    BTW, there is a mod that would generate a packing slip and xml file for Dazzle by me found here: http://www.zen-cart.com/index.php?ma...roducts_id=756

    It's quite incomplete, but you can probably reference it to complete yours.

    Steve.
    www.ToolUSA.com - Hand Tools for Jewelers, Crafters, Garden and Households. Also offers Safety Items and Scout Gadgets.
    www.OfficialCap.com - MLB Licensed Caps by New Era and NFL Licensed Caps by Reebok.

  5. #25
    Join Date
    Mar 2009
    Posts
    30
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    What if combining in the same observer class the watch of events coming from both classes and procedural code?

    like
    $this->notify('NOTIFIER_CART_ADD_CART_END');
    and
    $zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SUCCESS');

    is it possible?

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

    Default Re: Use Of Notifiers - How To

    Should be fine, since the observer class is still watching for the notifier point. Granted, if you're trying to use the observer class to alter something inside the procedural code loop, you'll have a little more difficulty than if you were watching a point that was hooked from inside a class. It may be necessary to set or use session variables or other global variables for those purposes. But, if you're just having the observer do something to a database record or sending an email, and not passing data back to the calling point, then things are pretty simple.
    .

    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. #27
    Join Date
    Mar 2009
    Posts
    30
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Thanks.
    I am still strugling with the observer concept
    first , in the free product example if I replace
    $_SESSSION['cart']->attach
    with
    $this->attach
    it does not work, why?

    regarding my original question
    if i put together
    $this->attach
    and
    $zco_notifier->attach
    in the same class, in a sample code
    Code:
    class calixto extends base {
    
     function calixto() {
    	     global $zco_notifier;
        $zco_notifier->attach($this, 
    			array(	  'NOTIFY_HEADER_START_PRODUCT_INFO'
    			 )
    	 );
    	
    	$_SESSION['cart']->attach($this, 
    			array(	'NOTIFIER_CART_ADD_CART_END', 			/* class shopping_cart */
    				   	'NOTIFIER_CART_REMOVE_END',				/* class shopping_cart */
    					'NOTIFIER_CART_UPDATE_QUANTITY_END',	/* class shopping_cart */
    					'NOTIFIER_CART_RESET_END'				/* class shopping_cart */
    			 )
    	 );
    	 
     }
    		
    
     function update(&$class, $notifier, $paramsArray) {
    	 if ( $notifier == 'NOTIFY_HEADER_START_PRODUCT_INFO' )
    		  $_SESSION['add_delivery'] = 'product_info';
    	else
    		  $_SESSION['add_delivery'] = 'the cart';
    
     }
    
    }
    update is called in the case of the first event
    if updating the CART, zencart stops, white screen
    I wonder about this scenario
    will each X->attach call generate different eventID?
    so that they cannot share same update function?
    thanks

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

    Default Re: Use Of Notifiers - How To

    Hopefully you got my email.

    But for others wondering about the same thing. I have to apologise.
    The documentation is wrong.

    You can use $this->attach to watch a notifier in the shopping cart class rather than $_SESSION['cart']->attach

    The trick is to change the autoloader.

    Documentation suggests using

    PHP Code:
    $autoLoadConfig[90][] = array('autoType'=>'class',
                                  
    'loadFile'=>'observers/class.freeProduct.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  
    'className'=>'freeProduct'
    however things will work if you use

    PHP Code:
    $autoLoadConfig[10][] = array('autoType'=>'class',
                                  
    'loadFile'=>'observers/class.freeProduct.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  
    'className'=>'freeProduct'
    Notice the load point for the class has been changed to 10.

    HTH

  9. #29
    Join Date
    Feb 2009
    Posts
    88
    Plugin Contributions
    1

    Default Re: Use Of Notifiers - How To

    Resurrecting an old thread. I'm working on 1.3.8a, trying to observe events on the shopping cart.

    I've been going crazy trying to use the notifier system. I've hacked the shopping_cart.php and would now like to extract my work into an observer so I can port my work more easily to other versions.

    My observer is loaded, instantiated, and the constructor is run, so the attach() call completes. However, I never get the update() method fired. I've spent over an hour looking at this and debugging with error_log() calls, but I don't see how the code is supposed to work.

    I'm wanting to hook onto NOTIFIER_CART_RESTORE_CONTENTS_START. The docs say I should create an observer and call "$this->attach($this, array('NOTIFIER_CART_RESTORE_CONTENTS_START'));" in the constructor. This succeeds, and $this->observers is added to, but the update() method is not called when the shopping cart calls "$this->notify(....)".

    Quote Originally Posted by wilt View Post
    You can use $this->attach to watch a notifier in the shopping cart class rather than $_SESSION['cart']->attach
    'base' has a $this->observers array, but the array isn't static, right? That is, my observer class (derived from base) has its own 'observers' array, distinct to the shopping_cart instance's observers array. I don't see why calling $this->attach() in my observer (which adds to $this->observers) would achieve the required callback hook when shopping_cart calls $this->notify().

    If I change my observer to use "$_SESSION['cart']->attach($this, array('NOTIFIER_CART_RESTORE_CONTENTS_START')" the notification works fine. (also have to change the auto_loader priorities to 90 and 90 - above we were instructed to use 10 and 90 but this breaks use of $_SESSION['cart']->attach()).

    I presume this was working fine in 1.3.8a (can't see anything in the changelog)? What could I be doing wrong?

    Thanks
    Nick

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

    Default Re: Use Of Notifiers - How To

    A number of things were addresed with respect to notifiers in v1.3.9. Have you tested the same thing in the latest version of Zen Cart yet?
    .

    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.

 

 
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Can I use notifiers to assist during product edits/updates?
    By vukan71 in forum General Questions
    Replies: 4
    Last Post: 6 Aug 2012, 04:59 PM
  2. How can I use Multiple mods that use same files?
    By sfklaas in forum General Questions
    Replies: 1
    Last Post: 8 May 2009, 10:27 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