What's it supposed to do? Is there a reason why you're loading your class so early in the start-up? Code point 10 is pretty early.
P.S. Just for grins-and-giggles, try changing changing Array to array in your attach call.
What's it supposed to do? Is there a reason why you're loading your class so early in the start-up? Code point 10 is pretty early.
P.S. Just for grins-and-giggles, try changing changing Array to array in your attach call.
Last edited by lat9; 5 Mar 2013 at 05:48 PM.
You are both right, thank you, it was late last night. I have it basically working, it's a way to 'activate' a customers 12 month site membership upon payment. Just a little more help to extract the payment method before allowing the update to occur would be great. Thanks.
Code:<?php // /includes/classes/observers/class.membersUpdate.php // // Observer class to activate members upon payment // // see also /includes/auto_loaders/config.membersUpdate.php class membersUpdate extends base { // CONSTRUCTOR METHOD function __construct() { $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL')); } // UPDATE METHOD function update(&$class, $eventID, $paramsArray = array()) { global $db; if (($_SESSION['cart']->in_cart('products_id', '1')) && ($_SESSION['payment'] != 'Cheque/Money Order')) { $db->Execute("UPDATE " . TABLE_CUSTOMERS ." SET customers_membership = '1' WHERE customers_id = '" . (int)$_SESSION['customer_id'] . "'"); } } } ?>
Got that sorted by using the payment_module_code field instead of payment_method. Now I don't seem to be able to filter by product ID. If I set productID) == FALSE, it works, but the ID is definitely '1'.
Code:<?php // /includes/classes/observers/class.membersUpdate.php // // Observer class to activate members upon payment // // see also /includes/auto_loaders/config.membersUpdate.php class membersUpdate extends base { var $productID = '1'; // CONSTRUCTOR METHOD function __construct() { $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL')); } // UPDATE METHOD function update(&$class, $eventID, $paramsArray = array()) { global $db; if (($_SESSION['cart']->in_cart($this->productID) == TRUE) && ($_SESSION['payment'] != 'moneyorder')) { $db->Execute("UPDATE " . TABLE_CUSTOMERS ." SET customers_membership = '1' WHERE customers_id = '" . (int)$_SESSION['customer_id'] . "'"); } } } ?>
Anyone got any clues? I've done some experimenting but can't get it to work unless in_cart is set to false, I'm finding it a little strange. There is only one product and it is ID 1. I've looked up the function and used many different types of syntax but still it only works if set to FALSE, as below:
Code:<?php // /includes/classes/observers/class.membersUpdate.php // // Observer class to activate members upon payment // // see also /includes/auto_loaders/config.membersUpdate.php class membersUpdate extends base { var $prod_id = 1; // CONSTRUCTOR METHOD function __construct() { $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL')); } // UPDATE METHOD function update(&$class, $eventID, $paramsArray = array()) { global $db; if (($_SESSION['cart']->in_cart($prod_id) == FALSE) && ($_SESSION['payment'] != 'moneyorder')) { $db->Execute("UPDATE " . TABLE_CUSTOMERS ." SET customers_membership = '1' WHERE customers_id = '" . (int)$_SESSION['customer_id'] . "'"); } } } ?>
In your last post, $prod_id is null, not declared (because you're using it as a local-scope variable, not the $this-> class variable), and so will never be found by in_cart, thus FALSE is an accurate response.
.
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.
Last edited by slobadog; 7 Mar 2013 at 10:46 AM.
Could it be that the products_id is actually the products_prid as I am using attributes for the different Membership levels? Would working zen_get_prid() into it somewhere fix the problem? Is there another way I could check that the products_id is indeed '1' before updating the customer table?
A little help? Please?
Ya, you didn't mention the attributes bit before.
Ajeh posted your answer in another thread asking the same question: http://www.zen-cart.com/showthread.p...92#post1184392 :
Code:$_SESSION['cart']->in_cart_check('products_id', $this->prod_id)
.
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.
Ah ha! That did the trick, thanks so much. I had seen that thread by Ajeh but wasn't considering the attributes thing myself at the time. You've solved a 3 day mystery for me, best I shout you a cappuccino!