unable to access checkout ,order, line_items liquid objects through application proxy setup.

ashok_tatikonda
Tourist
6 0 1

Hi All,

I need to get item level discount information, but Shopify.checkout object doesn't provide them ( many people reported this issue), and app can not access liquid objects on order status page, so I came up with alternative.

There are many links which mentions the above problem, but I am posting couple of them for reference

https://community.shopify.com/c/Shopify-Design/Get-applied-discount-for-line-items/td-p/74840

https://community.shopify.com/c/Shopify-APIs-SDKs/ScriptTag-with-Liquid-or-equivalent/td-p/246204

The alternative I thought is making use of app proxy concept provided by shopify, which allows liquid code as response and shopify executes this liquid code on page, which giving us to chance to access liquid objects on order status page.

I see that , its working perfectly fine, but not for checkout ,order, line_items liquid objects. If I access shop or customer, etc, its giving the details.

To make it more clear, I am pasting the liquid code that ran on order status page, and its result, you will see the same issue that I explained.

{% layout none %}
<script>
<h1>Hello {{customer.id}} {{ checkout }}</h1>
{% for discount_application in order.discount_applications %}
Discount name: {{ discount_application.title }}
Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}

{% for discount_application in checkout.cart_level_discount_applications %}
Discount name: {{ discount_application.title }}
Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}

{% for order in customer.orders %}
{% for discount_application in order.cart_level_discount_applications %}
id: {{ order.id }}
Discount name: {{ discount_application.title }}
Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}
{% endfor %}
 
{% for discount_application in order.discount_applications %}
id1: {{ order.id }}
Discount name: {{ discount_application.title }}
Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}
</script>

 

<===================================>

Response:


<script>
<h1>Hello 2914404270137565 </h1>

id: 2201739132985
Discount name: orderlevel
Savings: -Rs. 23.40


id: 2199531028537
Discount name: orderlevel
Savings: -Rs. 46.80

id: 2199530340409
Discount name: orderlevel
Savings: -Rs. 20.40

id: 2199528538169
Discount name: orderlevel
Savings: -Rs. 36.00
</script>

<==================================>

even though I used multiple for loops on different objects, only customer.* worked. unfortunately, it does not contain item level discounts.

I see that, when I place the same script in store's settings-> checkout-> additional scripts box, its working. since we are developing the app to have this functionality, we can't put it manually and I see there is no api to put a script in additional scripts box.

 

Any help on this would be much appreciated.

Thanks in advance, please do let me know if you need any more details to understand the issue.

0 Likes
ashok_tatikonda
Tourist
6 0 1

Please let me know shopify hides order, checkout, line_items for dummy orders which were placed through bogus gateway. I see shopify returning {{customer.order_count }}as 0, even though there are many orders for the same customers.

0 Likes