Solved

In custom app block, the selling_plan_allocations for variant does not have correct price

paro22
Shopify Partner
4 0 0

Hi there,

 

I'm following this guide to create an app for try-before-you-buy.

 

In the example code under "The selling plan selector on the product page", it mentions both "selected_selling_plan_allocation" and "selling_plan_allocations". However, when I test this, the allocation object still had the original price, not the lower purchase option price.

 

Here's how I'm testing it:

  1. I have a selling plan with $0 fixed due at checkout assigned to my test product.
  2. To make sure it's a server-side request that Liquid processes, I call the URL with both the variant and selling_plan: /products/the-3p-fulfilled-snowboard?variant=45203469238594&selling_plan=689019388226 
  3. I'm printing a few debug strings to see the values:
    1. current_variant.selected_selling_plan_allocation = SellingPlanAllocationDrop
    2. current_variant.selected_selling_plan_allocation.price = 262995 [this is where I expected $0]
    3. product.selected_selling_plan.checkout_charge.value = 0
 
So it seems like the product selling plan has the correct info, but the variant selling plan allocation does not. Based on the example code given in the docs, I expected the variant to have the necessary info to render the correct price.
 
Any ideas what I'm missing?
Accepted Solution (1)

qc11
Shopify Staff (Retired)
47 14 12

This is an accepted solution.

Hi!
There might be some confusion. The `current_variant.selected_selling_plan_allocation.price` refers to the amount that the customer is going to pay in the end. For try before you buy, this value equals to the full price.

I believe the value you are looking for in `selling_plan_allocation` should be the `checkout_charge_amount`: https://shopify.dev/docs/api/liquid/objects/selling_plan_allocation#selling_plan_allocation-checkout...

 

Hope this helps!

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 2 (2)

qc11
Shopify Staff (Retired)
47 14 12

This is an accepted solution.

Hi!
There might be some confusion. The `current_variant.selected_selling_plan_allocation.price` refers to the amount that the customer is going to pay in the end. For try before you buy, this value equals to the full price.

I believe the value you are looking for in `selling_plan_allocation` should be the `checkout_charge_amount`: https://shopify.dev/docs/api/liquid/objects/selling_plan_allocation#selling_plan_allocation-checkout...

 

Hope this helps!

To learn more visit the Shopify Help Center or the Community Blog.

paro22
Shopify Partner
4 0 0

Ah, that makes sense. I thought the example code in the docs would have already accounted for that.