Accessing automatic discounts in the cart page - shopify

I want to render stuff in the cart when a certain automatic buy-x-get-y discount exists, is there a way to access the discounts added in the admin discounts section then check their titles? If not, is there another way I can do so within the cart? Because the only other way I can think of is adding the y item to the cart if the total price >= x then checking the discounts array for the item then remove it if the discount am looking for is not there, its a solution but it requires sending 1, sometimes 2 unnecessary post requests to the database which I want to avoid.

Related

Shopify-Limit products is setted so when clients click cart button with over quantity, they get error

I'm shopify developer.
I want to set quantity limit so that if client try to add over limit quantity and click "cart" button, they get error message.
How can I implement this?
Thanks for seeing my question.
When you render a product, you have access to its current quantity. You are free to use this value. Take the example of a widget with 3 variants, A, B and C. A has 3, B has 6, and C has 9.
When you render your input element to capture quantity, you are aware of the variant in question, and the max quantity allowed (at the time the page rendered anyway). So you are free to limit the quantity to be less than the maximum available using simple HTML controls. With Javascript you can script this kind of stuff.
In the end though, by the time the customer reaches checkout, if say they asked for 3 of B, even though at that time B had 6, so 3 was good and allowed, at checkout, Shopify may reject their order as B may only have 2 at that time. Meaning they waited too long to purchase.
If Shopify did not work this way, people would hold inventory hostage while not buying. So in effect, even if you limit quantities, your customers may still be unable to purchase all they want.
Long story short, you can add quantity limits to the HTML element used to change the quantity going into the cart. Use the variant's current quantity from Shopify as the high limit.

Dynamic Variant Price while adding variant into the Shopify cart

I have Shopify Store, where customer can design/customise their product before buying it. and based on the design / customisation price of the selected variant may get varied. but I think Shopify does not facilitate to change variant price dynamically while adding into cart.
Is any solution there I might be missing ? Any help will be appreciated.
There are a few solutions none of which are great.
Quantity based
Make the product price $1 and based on the options increase the quantity in order to meet the required price. With a little code you can change the cart to look like it's a single product, but the checkout will not be OK.
Variant based
If the product will have only a few price changes you can create different variants and change the variants based on the selected options. For example 10 different variants for 10 different prices.
App based
You can use an App such as https://apps.shopify.com/product-options to create options that can modify the product price. ( this will add dummy products to the checkout as well )
For Plus, you can use shopify script to edit the line items directly.
If you're not Plus users, you have to do it on server-side, i.e. your backend
submit an ajax request on your custom product page
backend receives the request. Use admin API to create a new product variant on the fly
set the variant price, weight, quantity, or other properties based on your business rules
return response to client
client receives a successful response. use cart ajax to add the new variant to cart
let client continue checkout
Upon order is made, use webhook to update inventory or other information required. But there is a problem regarding variant limit. For each product, you can only add 100 variants.
So you need to create new products when the variant is used up for the product. Alternatively, you can delete the existing variants. But the variants in customer carts will be cleared.
I am doing something similar to what you're doing so I think our approach will be more or less the same. Basically, there are only 2 solutions, either create a new product or new discount dynamically. Both approaches create many dummy/garbage data

How do i add product option or a variant that increments the price - shopify?

I'm creating a custom feature on a Shopify theme and I need to add product options or variants that each increment a price by a certain amount.
For example, if I want to have wrapping on a product, that costs 10$ extra. I don't want to create a "wrapped" variant that costs product price + 10$, I want it to be dynamically calculated because I will be adding multiple such choices.
I then need to add the product to the cart via the Shopify AJAX API, so I will be needing to specify such added options in the request body somehow and have Shopify calculate the final price.
How would I go about doing this?
Prices in Shopify are attached to variants.
To say it simply you can't modify the price of a variant in any way. The price is set on creation of the variant and you can't modify the variant price from the front-end.
If you plan to modify the price based on the user input you need to create predefined variants for each option and change the selected variant based on the user input.
If you still want real dynamic price you will need to look for some kind of an App that will support this functionality.

How to hide out of stock products and its categories in Volusion

I have Volusion store I want to do the following, If it is possible??
If Qty = 0 (out of stock) do not display the product as well as it category.
When Qty changes display. (this will eliminate clutter)
If Product in Category = 0. Do not display the category
For example Home > New > Digital Signage has 0 products,
Then do not display the category - Until there are product in the category.
From Volusion's support article.
https://support.volusion.com/hc/en-us/articles/209957467-How-to-Use-the-Hide-When-Out-of-Stock-Option
How to Use the Hide When Out of Stock Option
When an order placed in your store causes the stock status of a product to drop to zero or below, your store will hide the product, provided the Hide When Out Of Stock setting (on the product's Advanced Info > Product Display tab) is set.
This will prevent the product from being viewed by customers on your store front until the product's stock value is incremented (either manually or through processing an RMA or purchase order). You can learn more about using the hide function by reviewing the Marking a Product as Hidden article.
Note that if any of your products have options for your customers to select from, you may wish to hide certain options when the associated product variant is out of stock, while leaving other options visible. The best way to automatically hide out-of-stock product options is by using Smart Match and the Inventory Control Grid.
Automatically Hiding When Out of Stock
Note that the Hide When Out Of Stock function only activates if the stock status of a product drops to zero or below due to a purchase. If you explicitly set the stock status to zero within a product's settings, it will not automatically trigger this setting. To manually hide a product from view on your store front, enable the Hide Product option within the Advanced Info > Product Display tab.
Furthermore, in order for products to automatically be hidden when out of stock, products need to be configured to not allow backorders. To do this, go to Settings > Config Variables and select the Checkout Variables. Make sure the Enable Back Orders check box is not selected. This will prevent Volusion from allowing any products at a stock less than 1 from being ordered and will allow the Hide When Out Of Stock variable to engage for all products.
If you have some products that you want to do this for and some you don't, you can set Enable Back Orders at a global level as described above but select the Do Not Allow Backorders check box for specific products under the Stock tab.
Note on Stock Value Updates
Briefly mentioned above, Volusion's Hide When Out Of Stock will inversely update products: Any product using this function will be automatically unhidden when the stock status for a product is updated to a positive quantity. Product stock can be updated manually from a product's settings page or automatically through the processing of an RMA or purchase order, or even through an import to your Volusion store's products table.
Also, please note that any product with Hide When Out Of Stock and Hide Product checked with a Stock Status set to Null (blank) or a positive value will be unhidden whenever any Stock Status is imported for any product in the store.
Please keep this function in mind when using this feature to prevent products you wish to remain hidden from being made available on your store front after product stock value updates.blockquote

Edit Shopify Metafields/Product Options

I'm using Shopify to run a sort of Kickstarter campaign on a custom product, whereby if the goal is reached the item will be made. I need to update the number of the items sold during the campaign, I'm storing the number sold as either a product option or metafield however right now i'd have to update these values manually every time one is sold.
My question is whether or not I am able to edit the value of a product variant option or metafield preferably using liquid - so that on completion of the order I can update the number of sold items.