The first form is correct. Use zco_notifier for procedural cases.
The first form is correct. Use zco_notifier for procedural cases.
That Software Guy. My Store: Zen Cart Support
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.
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?
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.
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:
Notice I'm trying 3 possible weight (in oz)?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('%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); } } ?>
$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.
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?
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.
.
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.