Results 1 to 8 of 8

Hybrid View

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

    Default Re: Product ID with numbers and letters

    Zen Cart has a products_model field. If you populate that with the SKU number, when you're inserting all their products into your database, then you could customize the code to do add-to-cart actions based on products_model instead of products_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.

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

    Default Re: Product ID with numbers and letters

    Quote Originally Posted by DrByte View Post
    Zen Cart has a products_model field. If you populate that with the SKU number, when you're inserting all their products into your database, then you could customize the code to do add-to-cart actions based on products_model instead of products_id.
    Another thing is that there are about 16k parts in one of the manufacturers catalog, I got to upload around 20 of them. And I have no idea what might be the chance that some of the parts could have same sku...

    But anyway, could you please tell me where do I look to change products_id to products_model

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

    Default Re: Product ID with numbers and letters

    Easy
    Just add a new file, as follows:

    /includes/extra_cart_actions/buy_now_by_model_number.php
    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= is set but no products_id is set,
     * then lookup products_id from products_model (m)
     */
    if (isset($_GET['action']) && $_GET['action']=='buy_now' && isset($_GET['m']) && !isset($_GET['products_id']))
    {
      $sql= "select products_id from " . TABLE_PRODUCTS . " where products_model = :themodel: LIMIT 1";
      $sql = $db->bindvars($sql, ':themodel:', $_GET['m'], 'string');
      $lookup = $db->Execute($sql);
      if ($lookup->RecordCount() == 1)
      {
        $_GET['products_id'] = $lookup->fields['products_id'];
        unset($_GET['m']);
        zen_redirect(zen_href_link($goto, zen_get_all_get_params('m')));
      }
    }
    Now you can use URLs like this:
    index.php?action=buy_now&m=THEMODELNUMBER

    .. where THEMODELNUMBER is the case-sensitive model number assigned to your products_model field in your database's products table. (Same as the model number on the admin edit-product screen)
    .

    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
    Nov 2011
    Posts
    21
    Plugin Contributions
    0

    Default Re: Product ID with numbers and letters

    Doc, you the best! The only thing you forgot is to close php

    THANK YOU!

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

    Default Re: Product ID with numbers and letters

    Quote Originally Posted by farmex View Post
    Doc, you the best! The only thing you forgot is to close php
    Actually, that was very intentional: https://www.zen-cart.com/tutorials/i...hp?article=313
    Quote Originally Posted by farmex View Post
    THANK YOU!
    You're welcome.
    Happy Thanksgiving.
    .

    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.

 

 

Similar Threads

  1. Can I make the telephone field accept only numbers and not letters
    By willy12 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 1 Jul 2015, 02:41 AM
  2. Resetting category and product numbers
    By Glock1 in forum General Questions
    Replies: 2
    Last Post: 4 Jan 2012, 05:32 PM
  3. Big Letters with translate, and wrong possition of site.
    By JimKarvo in forum General Questions
    Replies: 0
    Last Post: 18 Jun 2008, 10:33 AM
  4. Model Numbers With Product Options
    By DiZZ in forum General Questions
    Replies: 8
    Last Post: 17 Nov 2006, 04:16 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