Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Mar 2006
    Posts
    89
    Plugin Contributions
    0

    Default Notifier help please

    A little help with this would be good please. It doesn't throw an error but it doesn't work either:

    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 membersUpdate() {
                   $this->attach( $this, Array('NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION'));
        }
        
        // UPDATE METHOD
        function update(&$callingClass, $notifier, $paramsArray) {
    		global $db;
        	if ($_SESSION['cart']->in_cart('products_id', '1')) {
            $db->Execute("update " . TABLE_CUSTOMERS ." where customers_id = '" . (int)$_SESSION['customer_id'] . " set customers_membership = '4'");
    		}
    	}
    }
    ?>
    Code:
    <?php
    // includes/auto_loaders/config.membersUpdate.php   ... 
    //
    // Config for class to activate members on payment
    //
    // see also /includes/classes/observers/class.membersUpdate.php
    
        $autoLoadConfig[10][] = array('autoType'=>'class',
                                     'loadFile'=>'observers/class.membersUpdate.php');
    
        $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                     'className'=>'membersUpdate',
                                     'objectName'=>'membersUpdate');
    ?>
    Thanks!

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,870
    Plugin Contributions
    96

    Default Re: Notifier help please

    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.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Notifier help please

    Quote Originally Posted by slobadog View Post
    $db->Execute("update " . TABLE_CUSTOMERS ." where customers_id = '" . (int)$_SESSION['customer_id'] . " set customers_membership = '4'");
    I think your SQL is backwards.
    Usually the syntax is: UPDATE table SET values WHERE criteria
    But you're using: UPDATE table WHERE criteria SET values
    .

    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.

  4. #4
    Join Date
    Mar 2006
    Posts
    89
    Plugin Contributions
    0

    Default Re: Notifier help please

    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'] . "'");
    		}
    	}
    }
    
    ?>

  5. #5
    Join Date
    Mar 2006
    Posts
    89
    Plugin Contributions
    0

    Default Re: Notifier help please

    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'] . "'");
    		}
    	}
    }
    
    ?>

  6. #6
    Join Date
    Mar 2006
    Posts
    89
    Plugin Contributions
    0

    Default Re: Notifier help please

    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'] . "'");
    		}
    	}
    }
    
    ?>

  7. #7
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Notifier help please

    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.

  8. #8
    Join Date
    Mar 2006
    Posts
    89
    Plugin Contributions
    0

    Default Re: Notifier help please

    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?

  9. #9
    Join Date
    Mar 2006
    Posts
    89
    Plugin Contributions
    0

    Default Re: Notifier help please

    Quote Originally Posted by DrByte View Post
    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.
    I've tried
    Code:
    if (($_SESSION['cart']->in_cart($this->prod_id) == TRUE)
    and even
    Code:
    if (($_SESSION['cart']->in_cart(1) == TRUE)
    But that didn't work either. I've tried by placing 51 experimental orders so far, I'm sure it's a simple fix!
    Last edited by slobadog; 7 Mar 2013 at 10:46 AM.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Notifier help please

    Quote Originally Posted by slobadog View Post
    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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 $db-Execute() issue with fields... Please please please help.
    By Ooba_Scott in forum General Questions
    Replies: 11
    Last Post: 3 Oct 2012, 09:36 AM
  2. Observer Notifier NOTIFIER_CART_GET_PRODUCTS_END Help
    By Celtic in forum General Questions
    Replies: 2
    Last Post: 9 Jun 2011, 11:22 PM
  3. Replies: 4
    Last Post: 1 Oct 2010, 05:09 AM
  4. Notifier trouble
    By ogradyjd in forum General Questions
    Replies: 2
    Last Post: 23 Jun 2009, 12:46 AM
  5. Specific notifier question - experts please!
    By s_mack in forum General Questions
    Replies: 35
    Last Post: 22 Feb 2007, 08:01 AM

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