Jump to content

Add To Cart Programatically


embo

Recommended Posts

In CC3, I'd like to know if there is a way to add a product to cart using PHP.

IE: I'd like to just send the CustomerID = 123, ProductID = 11303 and Quantity = 2 

Is this possible?  When the customer logs in, they'll see the added product(s) in their cart.

EDIT: If this can be done in CC6, then I'm willing to do the upgrade... Anyone?

Link to comment
Share on other sites

  • 3 weeks later...

In CubeCart v6 (not sure about earlier versions) you can login as the customer via the admin panel; from there, you could certainly add products to the cart for them.

Adding products to customer carts without logging in as them could be done, but as far as I'm aware it is not supported out-of-the-box. I'm sure any developer would be able to help you code something like that.

Link to comment
Share on other sites

I figured it out and wrote some code to make it work.  Just had to learn this PHP thing.  What I was really after was the ability to edit orders.  I can now do that.  It took a bit of effort to figure out how all the pieces work in CC.  Had to modify existing code plus add a new editOrder.Inc.php.

I can't believe this was not natively built into CC3.  Users had to delete an item and try to remember what options they picked along with the notes they added (we have Estelle's Input Text Mod) then add the item back.  Not ideal.

Anyways... thanks for the response.

Link to comment
Share on other sites

That looks like the Admin section.  I was already able to edit the orders in there in v3 with Estelle's Add/Edit Orders Mod.  However, the users can not edit the options in the front end after adding an item to the cart.  With the modifications I made, then can edit the options and text.  They can also click on an Edit button in Order History page for Pending orders, and the code will clear the cart, and put the items from the order into the current basket with the associated options and text (Estelle's Text Input Mod).  Going through checkout will use the same Order Number to submit the order.

Link to comment
Share on other sites

Ah, I see now, you want the customers to be able to edit their orders. I'm not familiar with Estelle's Text Input Mod or any version of CubeCart prior to v6, but as far as I am aware, that is not possible in v6 - once the customer places the order, the only way it can be edited is by contacting the store admin / customer service and asking them to change it. I'm not sure if it is this way through an intentional design decision or that the ability to edit pending orders as a customer was just never implemented - you could create a feature request on GitHub and see what sort of response you get, but it sounds like you've already got yourself sorted out.

As for editing an in-progress shopping cart, I think that would be an excellent customer experience improvement, but care would need to be taken not to make the cart too cluttered. Perhaps an 'edit' link which takes you back to the product page with the options you've chosen pre-selected, where adding to the cart would replace whichever entry you clicked from?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...