Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Apr 2010
    Posts
    59
    Plugin Contributions
    0

    Default Products that can only be purchased once.

    Hello Zen Community,

    I've had some recent success with finding answers on the boards, so I figured I'd throw another nail biter out here to see what the masses think.

    I've been having some issues finding an appropriate thread for this, so if its already been discussed, please link me there.

    I need an addon/module that will allow for the creation of products to be bought only once by customer. The products are Feebie promotional items. I'd like the ability to sort the customers by IP and account so I don't have multiple people in the same house mooching Freebies.

    The sorting feature is just icing, but I'm desperate for the 'buy once per customer feature'.

    Any words of wisdom?

    Thanks in advance for the time and advice.

    Jonah

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Products that can only be purchased once.

    Is there anything that identifies these problems such as they all are in the same categories_id where that categories_id is set as these Products master_categories_id in the products table?

    You could write a look for the products_id or based on master_categories_id something and then use it in the function for the display on the add to cart/buy now buttons so that it will change it from a normal Add to Cart to something else like:
    You got yours!
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Apr 2010
    Posts
    59
    Plugin Contributions
    0

    Default Re: Products that can only be purchased once.

    Yes actually,

    The products in question have the same category ID, and at this point, theres no reason to think that would ever change. All of our special offers would be derived from the same cat. selection that remains unposted.

    Our plan is to send out a link...and a coupon code to initalize the free offers. For Example:

    One of our offers is meant to be free of cost the customer. So, the product itself is written in at 0.00$ and then the coupon code would activate free shipping. I'm aware that there are many other ways to get free shipping and products than to write it in as 0.00, but this is the best way for us currently with our other formatting and addons installed.

    Ajeh, can you write this php function you speak of? The master cat id is 17. I'd put a link up for you, but I don't want everyone to see them. Just putting that number up should keep it viewable to the wise and wonderful only.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Products that can only be purchased once.

    Yes I could ... but then I'd have to kill you ...

    This took me a bit to work out what I think is the best solution ...

    1 if not logged in and this is one of the Free Products, the customer is told to login ...

    2 if logged in the orders are checked to see if the customer has already obtained the product ...

    You can customize the function file:
    /includes/functions/functions_general.php

    and around line 1144 change it to read:
    Code:
        default:
          $return_button = $link;
          break;
        }
    
    // bof: do not allow customer to add to cart if already purchased
    // if not logged in and a free product make login
    if (!$_SESSION['customer_id'] && zen_get_products_category_id($product_id) == 60) {
      return 'login for free product';
    }
    
    if (zen_get_products_category_id($product_id) == 60) {
          $chk_product_purchased_query = "select distinct op.products_id, o.orders_id
                                  from " . TABLE_ORDERS_PRODUCTS . " op
                                  left join " . TABLE_ORDERS . " o on o.orders_id = op.orders_id
                                  where op.products_id = '". (int)$product_id . "'
                                  and o.customers_id='" . $_SESSION['customer_id'] . "'";
    
         $chk_product_purchased = $db->Execute($chk_product_purchased_query);
    
        if (!$chk_product_purchased->EOF) {
          return 'too bad so sad';
        }
    }
    
    // eof: do not allow customer to add to cart if already purchased
    
        if ($return_button != $link and $additional_link != false) {
          return $additional_link . '<br />' . $return_button;
        } else {
          return $return_button;
        }
      }
    This way you can prevent having to test in the cart later, after they login, if they already got it and remove it from the cart or make the customer remove it before checking out ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Products that can only be purchased once.

    NOTE: this assumes the master_categories_id on these Products is 60 ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Apr 2010
    Posts
    59
    Plugin Contributions
    0

    Default Re: Products that can only be purchased once.

    Too Bad, Sooo Sad....

    Ajeh wins again.


    Vote Ajeh for world dictator!

    Ajeh, this is phenomial work...Thank you.

    I must ask for a glass of milk, and request that I also get the code to make it related to individual items (not its catagorey ID). Do you like e-cigarettes? :-p

    Jonah Youngblood
    http://www.primevapor.com

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Products that can only be purchased once.

    Thanks for the offer but it is bad enough I smoke the dang things than try something else that has yet to be proven won't kill me ... I know these will eventually ... but then again ... I drank milk as a child so that will get me too ...

    Meanwhile ...

    You could adapt the code from:
    Code:
    if (zen_get_products_category_id($product_id) == 60) {
    to something like:
    Code:
    if ( in_array((int)$product_id, array(6, 200, 34)) ) {
    where 6, 200 and 34 are the products_id you do not want ...

    Or for both to cover that whole Category plus other individual products_id numbers:
    Code:
    if (zen_get_products_category_id($product_id) == 60 || in_array((int)$product_id, array(6, 200, 34))) {
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Apr 2010
    Posts
    59
    Plugin Contributions
    0

    Default Re: Products that can only be purchased once.

    I've noticed that Zen product ID's are usually called on with the master category ID followed by an individual product ID for that category.

    Just to make sure...Zen Cart does not overlap these individual product IDs? Meaning, that never at anytime any two products from any two category's would have the same ID?

    Oh, and I know solicitation on here is bad, so please don't think I'm trying to sell anything, but you said they weren't proven to be safe. I beg to differ.....several health studies have already been released, here's a prominent one from New Zealand that's fairly recent.

    If we had a toxic product, the FDA would shut us down very quickly.

    health report link: http://www.healthnz.co.nz/RuyanCartr...t30-Oct-08.pdf

    I often find that its the lack of information to be the most damaging aspect of the business my comrades and I are in.

    Thank you again for your help Ajeh, If I can ever offer you anything with reason as return...please do not hesitate to find me!

    With Profound Gratitude,

    Jonah

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Products that can only be purchased once.

    Not a problem ...

    The products_id of a Product is unique ... if you link a product to multiple categories there is still 1 product but that is referenced in the products_to_categories table to say which categories the Product is in ...

    The master_categories_id is used to identify which Category a Product is "owned" by as in if there is a pricing issue or a navigation issue the master_categories_id indicates which Category to follow ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Apr 2010
    Posts
    59
    Plugin Contributions
    0

    Default Re: Products that can only be purchased once.

    Good to know,

    Where is my error? I think its in the Session ID line for the customer...I'm a bit of a newbie at php.

    // bof: do not allow customer to add to cart if already purchased
    // if not logged in and a free product make login


    if (!$_SESSION['customer_id'] && ( in_array((int)$product_id, array(65, 64, )) ) {
    return 'login for free product';
    }


    if ( in_array((int)$product_id, array(65, 64, )) ) {
    $chk_product_purchased_query = "select distinct op.products_id, o.orders_id
    from " . TABLE_ORDERS_PRODUCTS . " op
    left join " . TABLE_ORDERS . " o on o.orders_id = op.orders_id
    where op.products_id = '". (int)$product_id . "'
    and o.customers_id='" . $_SESSION['customer_id'] . "'";

    $chk_product_purchased = $db->Execute($chk_product_purchased_query);

    if (!$chk_product_purchased->EOF) {
    return 'You have already received this offer!';
    }
    }

    // eof: do not allow customer to add to cart if already purchased

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v155 Also Purchased only shows 56 items once I upgrade to 1.5.5a
    By Kyle Rogers in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 4 Aug 2016, 10:16 PM
  2. v154 Products that can't be purchased with vouchers
    By kalastaja in forum General Questions
    Replies: 3
    Last Post: 15 Mar 2015, 04:54 PM
  3. v151 Options that add on once, even if multiple products added
    By val-ent in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 31 Jan 2013, 08:27 PM
  4. Replies: 0
    Last Post: 14 Nov 2011, 07:49 PM
  5. Limit number of products that can be purchased
    By USONE in forum General Questions
    Replies: 3
    Last Post: 24 Aug 2010, 09:18 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