Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Require product be added before checkout

    Searching, Asking before I attempt this.

    I have a product which has several attributes that contain info about an order, I want this product and attribute selections to be added to the shopping cart first before any others can be added or at least make this product and attribute selections required to be added before checkout process.

    Any Ideas?
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

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

    Default Re: Require product be added before checkout

    Suggest the latter approach, since some folks seem to insist on doing this "out of order." Instructive messaging on the shopping cart page will help guide them. (Be sure to go to the cart page after add to cart rather than staying on the product page.)
    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.

  3. #3
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Require product be added before checkout

    Quote Originally Posted by swguy View Post
    Suggest the latter approach, since some folks seem to insist on doing this "out of order." Instructive messaging on the shopping cart page will help guide them. (Be sure to go to the cart page after add to cart rather than staying on the product page.)
    I originally was thinking the latter approach would be the way to go, however I fear it would result in a higher abandoned cart %.

    The required product or "attributes" have additional costs and I think showing those costs upfront would be best.

    I think maybe a function or if statement that replaces the "add to cart" button with a "start your order" button that redirects to the required product first might do the trick.

    Thanks for the input Scott
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  4. #4
    Join Date
    Dec 2011
    Location
    Wisconsin, USA
    Posts
    674
    Plugin Contributions
    21

    Default Re: Require product be added before checkout

    I have had to do similar items before. Most of the time I have simply added an observer that redirects back to the shopping cart with a notify message saying that product "x" must be added, or back to the cart and say something something like you must add product "x" to the cart I search thru my files, maybe I can find some coffee that would speed this up. But the observer class is really the best solution IMHO.

  5. #5
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Require product be added before checkout

    Quote Originally Posted by bislewl View Post
    I have had to do similar items before. Most of the time I have simply added an observer that redirects back to the shopping cart with a notify message saying that product "x" must be added, or back to the cart and say something something like you must add product "x" to the cart I search thru my files, maybe I can find some coffee that would speed this up. But the observer class is really the best solution IMHO.
    Thanks @bislewl

    I got this sorted

    Now I gotta figure out how an item in the shopping cart can be edited, not duplicated with new attribute selections. LOL
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Require product be added before checkout

    Quote Originally Posted by rbarbour View Post
    Thanks @bislewlI got this sorted Now I gotta figure out how an item in the shopping cart can be edited, not duplicated with new attribute selections. LOL
    Couple of ways come to mind on "how" to do it. If the original item is the "first" selected (meaning it is your "template" item that had to be added before all else), then could set a session variable to the hashed products_id so that could easily pull it out of the list of product in the cart and then can make the changes necessary to the product and replace that item in the list of cart items.

    I say replace because the items are added in order and remain in that order even when stored to the user's saved cart. Otherwise, depending on how many of said item is allowed in the cart, could just reference back to the integer cast products_id looking through the cart for that item regardless of the existing attributes.

    Could also perhaps incorporate a separate flag (attribute?) with that product when first storing it and then as going through the cart product and identify the presence of that attribute to remove it and update the attributes.

    Note that there is also likely to be an issue and need to work around the "saved cart", which also depends on the allowance of a customer to login before checking out with a fully defined cart. If a customer has logged in, has added this "default" product that isn't really ready to purchase until it has been edited, then have to do some level of control on the cart being stored/retrieved. When it is retrieved as part of logging in, the old content is placed ahead of the existing content (generally speaking) so working the "first" position in the above option may produce erroneous results. Also, comes the question of allowance/possibility to have two of the "base" product.

    The other thing of note, depends on your "test" that the first product has been added. If it for some reason depends on the complete "hashed" products_id and not just the integer of it, then that somewhat throws a monkey wrench (spanner) into the works.

    That hashed value is actually useful in determining which attribute(s) if any have been added to the product in that all available attribute(s) can be cycled through to recreate that value (more difficult if a text field is included) to identify which attribute(s) were originally selected. This is why I recommended earlier to replace the product in the cart rather than just add/edit attributes. Also why I brought up the cart save portion of the login, logout, time-out after login issue.

    Whatever is chosen/done, ideally the solution would maintain compatibility with other expected behavior/operations to minimize any rework if other plugins were added.

    As to the format of the attributes, storage/retrieval is a little different once added to the cart/order. Recommend possibly using superglobals to maybe help with development if not already in use.
    Last edited by mc12345678; 15 Oct 2018 at 11:41 AM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Require product be added before checkout

    Quote Originally Posted by mc12345678 View Post
    Couple of ways come to mind on "how" to do it. If the original item is the "first" selected (meaning it is your "template" item that had to be added before all else), then could set a session variable to the hashed products_id so that could easily pull it out of the list of product in the cart and then can make the changes necessary to the product and replace that item in the list of cart items.

    I say replace because the items are added in order and remain in that order even when stored to the user's saved cart. Otherwise, depending on how many of said item is allowed in the cart, could just reference back to the integer cast products_id looking through the cart for that item regardless of the existing attributes.

    Could also perhaps incorporate a separate flag (attribute?) with that product when first storing it and then as going through the cart product and identify the presence of that attribute to remove it and update the attributes.

    Note that there is also likely to be an issue and need to work around the "saved cart", which also depends on the allowance of a customer to login before checking out with a fully defined cart. If a customer has logged in, has added this "default" product that isn't really ready to purchase until it has been edited, then have to do some level of control on the cart being stored/retrieved. When it is retrieved as part of logging in, the old content is placed ahead of the existing content (generally speaking) so working the "first" position in the above option may produce erroneous results. Also, comes the question of allowance/possibility to have two of the "base" product.

    The other thing of note, depends on your "test" that the first product has been added. If it for some reason depends on the complete "hashed" products_id and not just the integer of it, then that somewhat throws a monkey wrench (spanner) into the works.

    That hashed value is actually useful in determining which attribute(s) if any have been added to the product in that all available attribute(s) can be cycled through to recreate that value (more difficult if a text field is included) to identify which attribute(s) were originally selected. This is why I recommended earlier to replace the product in the cart rather than just add/edit attributes. Also why I brought up the cart save portion of the login, logout, time-out after login issue.

    Whatever is chosen/done, ideally the solution would maintain compatibility with other expected behavior/operations to minimize any rework if other plugins were added.

    As to the format of the attributes, storage/retrieval is a little different once added to the cart/order. Recommend possibly using superglobals to maybe help with development if not already in use.
    Thanks mc12345678,

    Unfortunately, all jibberish to me.

    I am a template guy, never needed to do anything like this till now. IMO this should be an out-of-box feature but it's bjust that, my opinion.

    I am going to play with it for a few days but not wasting much time on it. Been playing with other OS platforms, from an end user, not contributor, ZC is taking up too much off my time.

    I'll post changes and solution if it's accomplished fairly quickly, otherwise it's been fun.

    I appreciate all the input and possible ways to go about a soluyion.

  8. #8
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Require product be added before checkout

    Update....

    I'm sure this could have been done a different and easier way but this is what I did.

    Added a actionRemoveProd function to the shopping cart class
    Added a action to the shopping cart link
    Added an if (action), create modal, confirm edit button with a action on product info page
    Added an if (action) $_SESSION['cart']->actionRemoveProd ($_GET['products_id']); on click to confirm uses POST to ajax, deletes from cart. done via ajax so all product attributes remain
    Added an if (action) to change define "Add to Cart" to "Confirm Changes", on click adds new to cart as if it was edited..

    probable all wrong but works
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

 

 

Similar Threads

  1. How do I require someone to register before downloading my catalogue document?
    By agentx in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 29 Jun 2010, 03:08 PM
  2. Coupon discount before shipping added?
    By jbible in forum General Questions
    Replies: 2
    Last Post: 13 Jan 2010, 01:45 PM
  3. Replies: 6
    Last Post: 29 Apr 2009, 07:21 PM
  4. I want to require customers to accept terms before ordering
    By Tereadia in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 15 Apr 2009, 12:14 AM
  5. Require at least one other product to checkout
    By dharma in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 20 Jan 2009, 06:54 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