Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 38
  1. #11
    Join Date
    Dec 2006
    Posts
    6
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Hi all,

    I need to add a product to the shopping cart when the user is visiting the site for the first time and a new shopping cart object is created. Can anyone please help me with the event i should attach to? I was trying to attach to event 'NOTIFIER_CART_INSTANTIATE_END' but it does not work at all.

    Please help.

    Thanks
    Sumit Pilankar

  2. #12
    Join Date
    Apr 2006
    Location
    Sunny California
    Posts
    36
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Howdy All,

    Just a quick question regarding the procedural workaround code.

    If the notification that I am watching for happens in /includes/modules/checkout_process.php

    as

    $zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE');

    Is it right to assume that I need to implement my observer class with the procedural:

    Code:
    global $zco_notifier;
    $zco_notifier->attach($this, array('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE'));
    rather than the OOP version:

    Code:
    $this->attach($this, array('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE'));
    I suppose I could just do a simple test to find out, but for the benefit of those reading, I'll go ahead and put it here in writing.
    The Zen Cart Team is awesome, take a moment to Donate

    SureVital Health and Nutrition

  3. #13
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,621
    Plugin Contributions
    123

    Default Re: Use Of Notifiers - How To

    The first form is correct. Use zco_notifier for procedural cases.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

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

    Default Re: Use Of Notifiers - How To

    Hi!

    I'm trying to generate a file with shipping & order detail using the notifiers (NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL).

    The problem is that I need certain values be also included in the output file such as order id, product details and shipping weight.

    I think when the trigger calls for my notifier, it is attached to order.php class only and $order->variables works just fine (except $order->order_id).

    But I'd definitely like $shipping_weight (all cart weight + tare or large_tare) and $order_id be included.

    How do I pass variables from shipping.php class?
    And why wouldn't $order->order_id not working whereas $order->total_weight does?

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

    Default Re: Use Of Notifiers - How To

    Without looking in great detail, I suspect you will need to "global" the $shipping_weight variable in order to use it in your notifier class.

    Also global the $insert_id if you want the number of the current order.
    .

    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. #16
    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
    Without looking in great detail, I suspect you will need to "global" the $shipping_weight variable in order to use it in your notifier class.

    Also global the $insert_id if you want the number of the current order.
    Thanks Dr. Byte!

    'global'ling $insert_id worked. However, I still can't get the $shipping_weight to work, which I suspect that my observer is attached so well only to class order.php. Perhaps use a different notifier than NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL?

    Below is the code:

    Code:
    <?php
     class xml_generate extends base { 
       function xml_generate() {
         global $zco_notifier;
         $zco_notifier->attach($this, array('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL'));
       }
       function xml_config_switch() {
           if ( defined('GENERATE_XML') && (GENERATE_XML == 'false') ) {
              return false;
           } 
           return true;
       }
       function update(&$callingClass, $eventID) { 
           if (!$this->xml_config_switch()) return;
           global $order, $shipping_weight, $insert_id;
         //Begin USPS Domestic clause
         if (strpos($order->info['shipping_module_code'], 'usps') !== FALSE) {
         $xml_msg = "<DAZzle Layout='c:\endicia\dazzle7\Zebra Label.lyt' OutputFile='C:\endicia\dazzle7\xmlout\domestic" . strftime('&#37;Y%b%d-%H%M%S') . ".xml' Start='PRINTING' Test='YES' Prompt='NO' AutoClose='NO'>" . "\r\n";
      $xml_msg .= "<Package ID='1'>\r\n";
      if (strpos($order->info['shipping_method'], 'Parcel') !== FALSE) {$xml_msg .= "<MailClass>PARCELPOST</MailClass>\r\n";}
      if (strpos($order->info['shipping_method'], 'First') !== FALSE) {$xml_msg .= "<MailClass>FIRST</MailClass>\r\n";}
      if (strpos($order->info['shipping_method'], 'Priority') !== FALSE) {$xml_msg .= "<MailClass>PRIORITY</MailClass>\r\n";}
      if (strpos($order->info['shipping_method'], 'Express') !== FALSE) {$xml_msg .= "<MailClass>EXPRESS</MailClass>\r\n";}
      $xml_msg .= "<DateAdvance>0</DateAdvance>\r\n";
      $xml_msg .= "<PackageType>NONRECTPARCEL</PackageType>\r\n";
      $xml_msg .= "<Oversize>FALSE</Oversize>\r\n";
      $xml_msg .= "<WeightOz>" . ($order->total_weight * 16) . "</WeightOz>\r\n"; //works without handling charge
      $xml_msg .= "<WeightOz>" . ($shipping->shipping_weight * 16) . "</WeightOz>\r\n"; //returns 0
      $xml_msg .= "<WeightOz>" . ($shipping_weight * 16) . "</WeightOz>\r\n";  //returns 0
      $xml_msg .= "<Services>CertifiedMail='OFF' DeliveryConfirmation='OFF' ></Services>\r\n";
      $xml_msg .= "<Value>" . $order->info['total'] . "</Value>\r\n";
      $xml_msg .= "<Description>" . $order->products_ordered . "</Description>\r\n";
      $xml_msg .= "<ReferenceID>" . $insert_id . "</ReferenceID>\r\n";
      $xml_msg .= "<ToName>" . $order->delivery['firstname'] . " " . $order->delivery['lastname'] . " - " . $order->delivery['company'] . "</ToName>\r\n";
      $xml_msg .= "<ToAddress1>" . $order->delivery['street_address'] . "</ToAddress1>\r\n";
      $xml_msg .= "<ToCity>" . $order->delivery['city'] . "</ToCity>\r\n";
      $xml_msg .= "<ToState>" . $order->delivery['state'] . "</ToState>\r\n";
      $xml_msg .= "<ToPostalCode>" . $order->delivery['postcode'] . "</ToPostalCode>\r\n";
      $xml_msg .= "<ToEMail>" . $order->customer['email_address'] . "</ToEMail>\r\n";
      $xml_msg .= "</Package>\r\n</DAZzle>\r\n";
      $OutFile = "includes/xml/usps/domestic" . strftime('%Y%b%d-%H%M%S') . ".xml"; //Setting path n file name to USPS domestic
      } //End if USPS Domestic clause
      
      //Generate XML File
      $fp = fopen($OutFile, 'a');
      $fout = fwrite( $fp , $xml_msg );
      fclose($fp);
       }
     }
    ?>
    Notice I'm trying 3 possible weight (in oz)?

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

    Default Re: Use Of Notifiers - How To

    $order->total_weight is likely your only option.

    The $shipping_weight is only available in the shopping cart, which is empty after the order is placed.

    Or you could write your own weight recalculator using the weight calculations in the calculate() function of the shopping_cart 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.

  8. #18
    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
    $order->total_weight is likely your only option.

    The $shipping_weight is only available in the shopping cart, which is empty after the order is placed.

    Or you could write your own weight recalculator using the weight calculations in the calculate() function of the shopping_cart class.
    Thanks Dr. Byte.

    As I'm not much of a programmer, I'm just putting the static tare value matching what I've put on the configuration, unless there is a method of saving $weight in shopping_cart class to some other (global?) varible that does not get reset and passed onto my observer. Or should resetting of $weight commented out from shopping_cart class and be reset at the end of my observer?

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

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by SteveKim View Post
    a method of saving $weight in shopping_cart class to some other (global?) varible that does not get reset and passed onto my observer. Or should resetting of $weight commented out from shopping_cart class and be reset at the end of my observer?
    Options:
    a. extend the order database table to also store the total weight as calculated by shopping cart, and then write code to ensure that info gets stored appropriately
    b. add a $_SESSION['shipping_weight'] variable before the shopping cart is reset, and then refer to that during your observer activities
    c. alter the order-total class to store the weight in the shipping method details, and then extract that information during your export
    d. recalculate the entire weight from scratch, rewriting much of the shopping-cart 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.

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

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by SteveKim View Post
    I'm just putting the static tare value matching what I've put on the configuration, unless there is a method of saving $weight in shopping_cart class to some other (global?) varible that does not get reset and passed onto my observer.
    Try using this:
    Code:
     $_SESSION['cart']->weight
    .

    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 2 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