Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2009
    Location
    Nelson, NZ
    Posts
    26
    Plugin Contributions
    0

    help question Unique Product Models

    Hi there,

    is there a simple way to make ZenCart check to ensure that product models are unique when they are entered?

    I could add a function as follows:

    function checkUnique ($table, $field, $compared) { $tablenew=mysql_real_escape_string($table); $fieldnew=mysql_real_escape_string($field); $comparednew=mysql_real_escape_string($compared); $query="SELECT $fieldnew FROM $tablenew WHERE $fieldnew='$comparednew'"; $result=mysql_query($query); $num=mysql_num_rows($result); if($num==0) { return TRUE; } else { return FALSE } }

    and call that PHP validation with the collect_info
    checkUnique('products', 'product_model', $_POST['product_model'])==FALSE

    But I was really hoping that there would be a way of doing this without affecting the base code too much.

    Many thanks

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,151
    Plugin Contributions
    11

    Default Re: Unique Product Models

    If you are talking about making sure someone orders the right size t-shirt, it's there in the attributes.

    For instance, the Option would be Size with values of 5, 6, 7, and 8. You'd add Please Select as the default value, for display only. The system will require the customer to select a size.

  3. #3
    Join Date
    Oct 2009
    Location
    Nelson, NZ
    Posts
    26
    Plugin Contributions
    0

    Default Re: Unique Product Models

    Hi dbltoe,
    No I'm not talking about attributes. Each product in the cart has a unique ID, but also a unique product model. I want to check to ensure that the same model number isnt entered more than once.
    Cheers!

  4. #4
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,151
    Plugin Contributions
    11

    Default Re: Unique Product Models

    You can set the maximum amount to one, but that doesn't preclude two simultaneous customer orders.

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,696
    Plugin Contributions
    123

    Default Re: Unique Product Models

    Quote Originally Posted by securit View Post
    Each product in the cart has a unique ID, but also a unique product model. I want to check to ensure that the same model number isnt entered more than once.
    Using phpMyAdmin, create a unique index on products.products_model. The field will already need to be unique before you can do this; if it fails because you have duplicates you can find them by doing a count() of products_model. Once you have done this, inserts with a duplicate products_model will fail.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 

Similar Threads

  1. Adding Unique Product Models/Variations on Same Product Page
    By reyman01 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 7 Sep 2010, 09:29 PM
  2. Can I display multiple similar models of a product within a product page?
    By PhillyDee in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 7 Apr 2010, 02:49 PM
  3. Different models of same product - show different absolute prices
    By ffredrik in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 9 Feb 2010, 07:14 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