Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Same model number, different manufacturers/products

    Here's what I got so far. I added two products with same model number, different price and name for testing.

    Here's extra cart action

    Code:
    if (isset($_GET['action']) && $_GET['action']=='buy_now' && isset($_GET['m']) && isset($_GET['aribrand']) && !isset($_GET['products_id']))
    {
      $sql= "select products_id from " . TABLE_PRODUCTS . " where products_model = :themodel:";
      $sql= "select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = :brand:";
      $sql = $db->bindvars($sql, ':themodel:', $_GET['m'], 'string');
      $sql = $db->bindvars($sql, ':brand:', $_GET['aribrand'], 'string');
      $lookup = $db->Execute($sql);
      if ($lookup->RecordCount() == 1)
      {
        $_GET['products_id'] = $lookup->fields['products_id'];
    	unset($_GET['aribrand']);
    	unset($_GET['m']);
    	zen_redirect(zen_href_link($goto, zen_get_all_get_params('m')));
      }
    }
    ?>
    if I use this string

    Code:
    index.php?action=buy_now&m=aaa111sss&aribrand=17
    it adds product by its manufacturer and model. But when using other manufacturer it's not adding anything to cart

    Code:
    index.php?action=buy_now&m=aaa111sss&aribrand=4
    Another question I ran in to is, how can I define that manufacturers_id = 17 = EXM?

  2. #2
    Join Date
    Nov 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Same model number, different manufacturers/products

    Got it working and picking product by its manufacturer and model.

    So the last question I have is how can I define that if manufacturers_id=17 it also is "EXM"


    Here's working extra cart action, if anybody would need it

    Code:
    <?php
    /**
     * Custom shopping Cart actions
     *
     * @package initSystem
     * @copyright Copyright 2003-2011 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    
    /**
     * check whether an "action" has been set. And if m= & aribrand= is set but no products_id is set,
     * then lookup products_id from products_model (m) and manufacturers_id (aribrand)
     */
    if (isset($_GET['action']) && $_GET['action']=='buy_now' && isset($_GET['m']) && isset($_GET['aribrand']) && !isset($_GET['products_id']))
    {
      $sql= "select products_id from " . TABLE_PRODUCTS . " where products_model = :themodel: && manufacturers_id = :brand: LIMIT 1";
      $sql = $db->bindvars($sql, ':themodel:', $_GET['m'], 'string');
      $sql = $db->bindvars($sql, ':brand:', $_GET['aribrand'], 'string');
      $lookup = $db->Execute($sql);
      if ($lookup->RecordCount() == 1)
      {
        $_GET['products_id'] = $lookup->fields['products_id'];
    	unset($_GET['aribrand']);
    	unset($_GET['m']);
    	zen_redirect(zen_href_link($goto, zen_get_all_get_params('m')));
    	zen_redirect(zen_href_link($goto, zen_get_all_get_params('aribrand')));
      }
    }
    ?>

  3. #3
    Join Date
    Nov 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Same model number, different manufacturers/products

    It was nice talking to myself, but I figured out last question I had

    Code:
    if ($_GET['aribrand'] == TO) {$_GET['aribrand'] = 4;}
    if ($_GET['aribrand'] == EXM) {$_GET['aribrand'] = 17;}

 

 

Similar Threads

  1. How do I get the Model Number on the same line as Model??
    By MandyMac in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 28 Jul 2014, 04:27 AM
  2. Replies: 2
    Last Post: 12 Nov 2010, 11:43 PM
  3. Manufacturers Product code/model number
    By BINKOBA in forum General Questions
    Replies: 0
    Last Post: 15 Dec 2009, 05:07 AM
  4. Different Model number for different attribute
    By underworldmagic in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 25 Dec 2006, 11:05 PM
  5. Adding different model numbers on same product
    By atljar in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 18 Sep 2006, 05:09 PM

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