Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    9,922
    Plugin Contributions
    3

    Default echo a message if total in cart from a specific manufacturer = XXX

    I need a method for the cart to calculate the total value of items from a specific manufacturer, and if the total of items in the cart from that manufacturer does not exceed a certain value, then a message is echoed in the cart screen.

    The cart can contain products from many manufacturers, so it needs to work out the total from that specified manufacturer. If the total in cart from manufacturer XYZ < 1000, then echo a special message.

    Checkout is still permitted - we just need to alert customers to a certain condition, if total from manufacturer XYZ are less than $1000.

    If the total value in cart from manufacturer is greater than 1000, then no message needed.
    Did my post help you fix something? You can show your gratitude by buying the the dev team coffee.

  2. #2
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    9,922
    Plugin Contributions
    3

    Default Re: echo a message if total in cart from a specific manufacturer = XXX

    I know it has something to do with the shopping cart class area... but what? (I also know it's not an easy task... Too many variables on the pricing side.)

    Basically, can I tweak this... and if so, how ?

    PHP Code:
      /**
       * Method to calculate the number of items in a cart based on an abitrary property
       *
       * $check_what is the fieldname example: 'products_is_free'
       * $check_value is the value being tested for - default is 1
       * Syntax: $_SESSION['cart']->in_cart_check('product_is_free','1');
       *
       * @param string product field to check
       * @param mixed value to check for
       * @return integer number of items matching restraint
       */
      
    function in_cart_check($check_what$check_value='1') {
        global 
    $db;
        
    // if nothing is in cart return 0
        
    if (!is_array($this->contents)) return 0;

        
    // compute total quantity for field
        
    $in_cart_check_qty=0;

        
    reset($this->contents);
        while (list(
    $products_id, ) = each($this->contents)) {
          
    $testing_id zen_get_prid($products_id);
          
    // check if field it true
          
    $product_check $db->Execute("select " $check_what " as check_it from " TABLE_PRODUCTS " where products_id='" $testing_id "' limit 1");
          if (
    $product_check->fields['check_it'] == $check_value) {
            
    $in_cart_check_qty += $this->contents[$products_id]['qty'];
          }
        }
        return 
    $in_cart_check_qty;
      } 
    If anyone has any pointers I'd be very grateful.
    Did my post help you fix something? You can show your gratitude by buying the the dev team coffee.

  3. #3
    Join Date
    Jan 2004
    Posts
    58,464
    Blog Entries
    3
    Plugin Contributions
    111

    Default Re: echo a message if total in cart from a specific manufacturer = XXX

    Starting with that function as a potential starting-point, one could possibly use something like this as an additional function (method) added to that class:
    Code:
        function in_cart_check_value_for_manufacturer($mfg_id = 0, $check_threshold=0) {
          global $db;
          // if nothing is in cart return 0
          if (!is_array($this->contents)) return 0;
          
          // if no mfg, abort
          if ($mfg_id == 0) return 0;
        
          // compute total for field
          $in_cart_check_value=0;
        
          reset($this->contents);
          while (list($products_id, ) = each($this->contents)) {
            $testing_id = zen_get_prid($products_id);
            $result = $db->Execute("select * from " . TABLE_PRODUCTS . " where products_id='" . $testing_id . "' and manufacturers_id = '" . (int)$mfg_id . "' limit 1");
            $in_cart_check_value += number_format($this->contents[$products_id]['qty'] * $result->fields['products_price'], 2);
          }
          return $in_cart_check_value;
        }
    This calculates based on the product's primary price, agnostic of any discounts such as sales or specials, and ignores the addition of any taxes (or if tax-included pricing is turned on, it will of course include taxes because tax is included in prices in that case).
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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.

 

 

Similar Threads

  1. CKeditor 3.4 Installation FYI with Zen cart 1.3.xxx
    By AlanL in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 5 Sep 2010, 08:38 AM
  2. Echo Cart Summary?
    By philip937 in forum General Questions
    Replies: 4
    Last Post: 17 Nov 2009, 11:45 PM
  3. Starting at: £xxx TEXT, I want to remove this from listings?
    By eggrush in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 31 Mar 2009, 04:27 AM
  4. Specific manufacturer charge mod???
    By I.Q in forum General Questions
    Replies: 3
    Last Post: 10 Mar 2007, 06:12 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
  •