Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default First Notifiers upon clicking "add this to my cart"

    Can someone please identify the first several notifiers encountered when a customer clicks "Add this to my Cart" on a product page?

    Thank you!

    Dave

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default Re: First Notifiers upon clicking "add this to my cart"

    They're not notifiers, per se, but after you've clicked "Add to Cart" (or any other cart-related action) the file /includes/main_cart_actions.php performs some of the first processing for the subsequent page-load. The first thing it does is to load and run any .php files present in /includes/extra_cart_actions.

    You can see what goes on in /includes/main_cart_actions.php to get a feel for what actions are available to process.

  3. #3
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: First Notifiers upon clicking "add this to my cart"

    Thanks lat9. I can see where additional processing could be added in extra_cart_actions.php. Following the processing there, case add_product is executed which executes actionAddProduct in includes/classes/shopping_cart.php. I get lost there and fail to comprehend where processing goes from there. Still no notifiers encountered!

    Dave

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default Re: First Notifiers upon clicking "add this to my cart"

    Perhaps if you'd describe what processing you'd like to perform after the customer clicks "Add to Cart", I could give you a more informed answer.

    If you want to do something in addition to the "standard" add-to-cart processing, I initially sent you to the right place. Take a look, for example, at Limit Quantities for Downloads and Virtual Products. That plugin inspects the products going into a cart on an 'add_product' or 'update_product' action before the standard cart-handler and either allows the addition/update or refuses it with a message to the customer.

    The cart-related actions are one place where the additional code can override processing without hooking a notifier.

  5. #5
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: First Notifiers upon clicking "add this to my cart"

    I'm trying to implement donations on my site. I currently have set up a product with cost of $1.00, so the customer can establish a donation by setting quantity. But this approach does not appear very professional since the shopping cart and other checkout pages show a unit price of $1.00, the customer selected quantity and the total donation. I would much rather have a quantity of 1 and the unit price and total price equal to the donation.

    The processing I want to perform is to set the quantity purchased to 1 and the product unit price to the quantity entered (for the donation product only). In other words, I want to reverse quantity and unit price for donation product when the user clicks "add to cart". So I've been looking for a notifier where the user entered quantity has been processed on the server side and the unit price has been extracted from the database but before any display on the shopping cart page or sidebox shopping cart, and that the new quantity and unit price will persist through the remaining checkout pages.

    The extra cart actions approach seems to me to be located too early in the processing as I don't believe quantity and unit price have been determined yet. I have made several mods using the notifier approach with great success. The problem now is to find a notifier best suited to the processing needed and that's where I get lost.

    Note that this approach is an experiment. I'm not sure it will work especially with post-sale admin report generation. But I want to try!

    Thanks for any advice!

    Dave

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default Re: First Notifiers upon clicking "add this to my cart"

    Dave, you're right; the extra_cart_actions is too early for what you want to do. You'll need to get very familiar with the inner workings of /includes/classes/shopping_cart.php to get the effect you want for the storefront and you'll also need (as you indicated) to do some changes to the admin orders-related processing (for invoices and packingslips) to get it all tied together.

    Here are a couple of the notifiers that you'll need to play with:
    1. NOTIFIER_CART_COUNT_CONTENTS_START ... I'm assuming that you want your donation product to show as a single item in the cart ...
    2. NOTIFIER_CART_GET_PRODUCTS_END ... Here's where the products (and quantity) currently in the cart are determined and returned as an array. I'm guessing that you could just swap the quantity and final_price elements for your donation product.

    There might be others within the shoppingCart class, but those two will get you started. You'll need to verify the display/operation of the shopping_cart, checkout_confirmation and account_history_info pages at a minimum to make sure that the display is what you want as well as how the confirmation emails go out to the customer.

  7. #7
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: First Notifiers upon clicking "add this to my cart"

    lat9, thanks. I initially tried NOTIFY_HEADER_END_SHOPPING_CART without much success. I had been looking at NOTIFIER_CART_GET_PRODUCTS_END and am about to test it. I haven't looked at NOTIFIER_CART_COUNT_CONTENTS_START yet but will. Thanks again for the advice!

    Dave

  8. #8
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: First Notifiers upon clicking "add this to my cart"

    I give up. Very frustrating and I'm very disappointed.

    Dave

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default Re: First Notifiers upon clicking "add this to my cart"

    If you'd post the code that you've got (along with what does/doesn't work), I might be able to help ...

  10. #10
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: First Notifiers upon clicking "add this to my cart"

    lat9,

    The first problem is I can't access the variable I want to change in the observer class triggered by NOTIFIER_CART_GET_PRODUCTS_END notifier. I want to access $products_array that is set near the end of function get_products in includes/classes/shopping_cart.php. This variable is set just prior to the NOTIFIER_CART_GET_PRODUCTS_END notifier.

    Code for my observer class and autoloader config files follow: Note that the observer class code simply prints out the $eventID and $products_array variable. All I see is the $eventID. No data is printed for the $products_array. So the observer class is being executed but the $product_array is not accessible.

    PHP Code:
    <?php
    /**
     * observer class to process donation entry box
     *
     * @package classes
     * @copyright Copyright 2003-2013 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: class.processDonationEntry.php   $
     */
    class processDonationEntry extends base {

     
    /**  constructor method !
       *
       * Attach observer class to the global $zco_notifier and watch for a single notifier event.
       */
      
    function __construct() {
          
    $this->attach($this, array('NOTIFIER_CART_GET_PRODUCTS_END'));
      }


     
    /**   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 
    $products_array;
        echo 
    "eventID: " $eventID;
    //    echo "<pre>"; print_r($_SESSION); echo "</pre>";
        
    echo "<pre>"print_r($products_array); echo "</pre>";
      } 
    // end of function update
    // end of class
    PHP Code:
    <?php
    /**
     * autoloader activation point for donation entry box processing
     *
     * @package initSystem
     * @copyright Copyright 2003-2013 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: config.processDonationEntry.php $
     */
    /**
     * Autoloader to instantiate observer class
     */
    $autoLoadConfig[203][] = array('autoType'=>'class',
                                  
    'loadFile'=>'observers/class.processDonationEntry.php');
    $autoLoadConfig[203][] = array('autoType'=>'classInstantiate',
                                  
    'className'=>'processDonationEntry',
                                  
    'objectName'=>'processDonationEntry');
    Dave

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v150 page is blank after clicking"add this to my cart" button
    By kevin_remy in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 4 Nov 2015, 09:10 AM
  2. v139h SOLVED: When clicking "Add to Cart", message shows "Your Shopping Cart is Empty"
    By bryanearl in forum All Other Contributions/Addons
    Replies: 9
    Last Post: 14 Nov 2012, 05:22 PM
  3. Replies: 0
    Last Post: 19 Sep 2012, 07:03 PM
  4. Replies: 0
    Last Post: 17 Mar 2010, 05:24 PM
  5. Clicking "Add to Cart" on a review delivers "product not found"
    By bifficus in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Nov 2007, 10:11 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