Shopping cart - the right way? - e-commerce

I need to implement shopping cart for my website. I decided to store carts in database rather that in session. My website serves as a platform for selling items between users. That said, users can edit their own products any time.
I understand that I can't just use product ID in the cart, because user need to get whatever he put to the cart. If the product is being changed after he put it to the cart, it shouldn't affect what he ordered, correct?
How is it usually solved? Should I copy entire product to the cart? Or maybe rather save versions of particular product and link to them? Another idea would be to inform customer on checkout that the product changed.
How is it solved in popular e-commerce platforms?

I understand that I can't just use product ID in the cart, because
user need to get whatever he put to the cart. If the product is being
changed after he put it to the cart, it shouldn't affect what he
ordered, correct?
the product price is going to change. the inventory is going to change. if a product goes out of inventory you want the customer to know so they can make another choice. if the product price has gone up or down, the cart should reflect the current price. so that means the cart will check the product table for the product pricing and inventory at different steps before the final transaction.
as part of the cart to product lookup -- if the pricing has changed you can alert the user. just as important - if the customer has ordered quantity 4 of a product, but the inventory has gone down to just 3 of them -- you have to change the cart and make it very obvious to the customer what just happened.
there are only two things the cart is responsible for - the product id, and the quantity to be sold. anything else stored in the cart is just to make it easier to display the product on the cart page or information needed for the merchant.

Related

On user selection, set product price to 0 for cart, checkout in shopify

I am facing a issue in shopify. The issue is I am listing products on a page with price. But i want whatever first 3 products customer click should be free for them. The fourth one they click should be of price set on backend.
So basically all products will have price. But first 3 client select should be free for them. Is this customization possible in shopify?
You have two choices. One, you use Shopify Plus, and with that you are free to script the checkout and change prices to free on items in the checkout. Or two, without Plus, you are free to use Discount Codes to bring the price of a checkout down to zero for items that meet criteria you setup. Those are your only sane choices at this time.

Recalculate discounts in prestashop cart

I'm working on prestashop shop where are used coupon with % discounts. We don't want to use coupons on products on sale but still want to buy products on sale and normal products in the same cart. I want to recalculate discounts in cart and order to apply only on non-sale products. I need help which file I should edit or where add functions to do it.
You should create a module that adds dedicated cart rules or customer-related specific prices on the products you are interested in when customer changes his cart or validate the order.
There are plenty of native Prestashop hooks you can use for that so you don't need tweaking with the core.
Keep in mind that there are a lot of "advanced cart rules" modules out there, so consider having a look before reinventing the wheel.

Shopify update the inventory for the custom bundle

I am trying to create a bundle for the Shopify site. I do not want to use the Shopify app to create the bundle. Product A has 30 variants. A customer has to buy 6 quantity of variants at a time. It could be any 6 variants. How can I update the inventory for all the variants when the checkout is done?
You don't update inventory, Shopify updates inventory. Your job instead is to ensure the correct number of variants go into the checkout. If you have trouble with that, you can always help yourself out with some clever product manipulations. Another solution is to listen to the checkout and examine the products sold. You can then alter inventory levels to suit your needs.
Almost all the bundle Apps do the same thing. You can try them out and see if that squares your circle. I made one of the original bundlers whereby I had it so in a bundle, made of N products, the merchant could tag each variant for a specific quantity, and then the customer would be buying those specific quantities when buying the product. I would use Ajax calls to check quantity live, and when the product was purchased I would then deduct the right inventory quantities because the product itself had infinite quantity.
That was very sophisticated and worked most of the time, but completely messed up when customers would SIT on the cart. Inventory levels would change, and valid carts at the time would become stale, and inventory would be messed up, resulting in overselling stock. Me bad. Shopify bad. Bundling bad. With Shopify Plus, all that kind of went out the window, and bundles are much easier. Without Plus, you gamble!

How to bundle product in shopify?

I tried to develop a Shopify application and I needed to bundle some products and sell those together with the special discount values.
There are some apps like product-bundle but I need bundling product in my app.
I tried to create one product similar to them and after the purchase completed I delete it but I think it's not a good solution because this product will be shown to shop and other customers can purchase that while I want to offer this product to a certain customer only.
In another way, I tried to use Shopify discount but can't satisfy my need or maybe I can't find true ways.
How can I do that?
There are multiple ways in which you can handle this.
1) Create a product itself:
Create a single product indicating a combination of your desired multiple products and combination of your price.
When the customer adds all the related products, detect it from cart webhook and update the cart of the customer by removing such products and adding the single product(i.e combination of all products).
2) Create a discount code: Create a discount code with your desired discount amount for each combo. Detect the products in the cart by cart webhook, if combo products found automatically apply the coupon to the cart.

Shopify: Is it possible to update the price of a product at checkout in the liquid template?

If a buyer purchases an item from a Shopify store, we would like to customise the system such that the buyer can select another product from a specific collection in the same store for free with that purchase i.e. buy a premium dvd and receive another dvd for free (where the free dvd must be choosen from a specific collection).
Any suggestions on how best to achieve this?
Would it be possible to edit (hack) the theme's cart template to set the price to zero for the second free item added to the cart if it is in the specific "free" collection?
If you iterate through a cart and find a "premium" product in it with no "free" upsell product, you would render the collection "free stuff" for the customer, and they could pick from that collection. The products in the Free collection are indeed free.
And if you render a cart with an item from the Free collection and NO Premium item is in the cart, you probably want to disable checkout.
Would that be "good enough"?
You can create discount codes that can be applied to a single item in a collection. You can simply set the discount for that item to be 100% off.