Results 1 to 10 of 17

Hybrid View

  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!]
    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!]
    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!]
    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

 

 

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

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