Results 1 to 6 of 6
  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default How to change customer information/status after product order?

    I'm listed this as customer information because it's really just the outline I need. Actually, I'm wanting to change the permission status from the Category Specific Access Restriction plugin.

    This will make the site a members site where they have to pay to get access. There's only one product - the subscription fee and once they pay the permission status would change automatically.

    I'm thinking this could be done at the checkout success stage and would only take a couple of lines of an sql query.

    On an additional note, that change would not normally be inserted into the session so that the customer would have to log out and log back in so adding to the existing session would also be of help.

    If there is a better place to do this in the checkout process, let me know. If you happen to have some code, better still.

    Thanks in advance.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  2. #2
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: How to change customer information/status after product order?

    I do love answering my own questions and here's part of it

    in the header_php.php for checkout_success I added these lines:

    $customerID = $_SESSION['customer_id'];

    $permissions_query = "UPDATE " . TABLE_CUSTOMERS . "
    SET customers_privileges = 1
    WHERE customers_id = '$customerID'";
    $permissions = $db->Execute($permissions_query);

    That worked to insert the correct permission. Then the next was to change the session variable so that they don't have to log out and log back in:

    $_SESSION["customers_privileges"] = "1";

    This has worked - my php skills may not be the greatest so if this needs tweaking, please tell me!

    This can be used to change the person authorization level as well by substituting customers_authorization for customers_privileges.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

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

    Default Re: How to change customer information/status after product order?

    How about an observer class like this:

    PHP Code:
    <?php
    /**
     * observer class to set customer subscription status after purchase
     *
     * @package classes
     * @copyright Copyright 2003-2016 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: Should work on zc v1.5 and 1.6 $
     */
    class updateCustomerSubscriptionStatusAfterPurchase extends base {

     
    /**  
       * Attach observer class to the global $zco_notifier and watch for a single notifier event.
       */
      
    function __construct() {
        
    // Using NOTIFY_CHECKOUT_PROCESS_HANDLE_AFFILIATES because the $_SESSION['order_summary']['products_ordered_ids'] is set just before that.
        
    $this->attach($this, array('NOTIFY_CHECKOUT_PROCESS_HANDLE_AFFILIATES')); 

        
    $this->subscription_product_id 77// set the product_id of your subscription product here
        
    $this->subscribed_privilege_level 1// set the permission level to be granted by this product here
      
    }


     
    /**   
      * Actual Method that does the desired activity
      * Called by observed class when any of the notifiable events occur
      *
      * @param object $class
      * @param string $eventID
      * @param array $paramsArray
      */
      
    function update(&$class$eventID$paramsArray = array())
      {
        global 
    $db;
        
    $customer_id $_SESSION['customer_id'];
        
    $purchased_products_array explode('|'$_SESSION['order_summary']['products_ordered_ids']);
        if (
    in_array($this->subscription_product_id$purchased_products_array)) {
          
    $sql "update " TABLE_CUSTOMERS "
                  set customers_privileges = " 
    $this->subscribed_privilege_level "
                  where customers_id = " 
    . (int)$customer_id;
          
    $db->Execute($sql);
          
    $_SESSION['customers_privileges'] = (int)$this->subscribed_privilege_level;
        }
      }

    }
    .

    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
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: How to change customer information/status after product order?

    Oh, my word!!!

    Now that's elegant and I never ever would have gone there. That would go into classes > observers? Man, that's valuable info!
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

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

    Default Re: How to change customer information/status after product order?

    Ya. /includes/classes/observers/class.updateCustomerSubscriptionStatusAfterPurchase.php

    You'd need a config file for it too, depending what version of ZC you're using:
    /includes/auto_loaders/config.updateCustomerSubscriptionStatusAfterPurchase.php
    Code:
    <?php/**
     * autoloader for updateCustomerSubscriptionStatusAfterPurchase observer
     *
     * @copyright Copyright 2003-2016 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
      */
    $autoLoadConfig[190][] = array('autoType'=>'class',
                                  'loadFile'=>'observers/class.updateCustomerSubscriptionStatusAfterPurchase.php');
    $autoLoadConfig[190][] = array('autoType'=>'classInstantiate',
                                  'className'=>'updateCustomerSubscriptionStatusAfterPurchase',
                                  'objectName'=>'updateCustomerSubscriptionStatusAfterPurchase');
    Related example: https://www.zen-cart.com/showthread....74#post1147074
    .

    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. #6
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: How to change customer information/status after product order?

    Good deal. l will try to make time to package up a mod for this. Super cool!
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

 

 

Similar Threads

  1. v150 Action after change order status in admin
    By puhycz in forum General Questions
    Replies: 2
    Last Post: 17 Jun 2014, 12:21 PM
  2. change order status but do not want to send customer email
    By jrf in forum Managing Customers and Orders
    Replies: 6
    Last Post: 10 May 2009, 09:40 PM
  3. Email to customer after Order status update
    By awk_grep in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 13 Mar 2007, 07:13 PM
  4. Cannot change Customer Order Status
    By kevinmc3 in forum General Questions
    Replies: 3
    Last Post: 11 Sep 2006, 02:57 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