Shopify API CARTS - Changing line_item line_price

2019-07-21 10:35发布

Shopify has a CARTS api but it is read-only. I am trying to find a way to manipulate the line_item's line_price or price attribute. Shopify support has directed me here for an answer.

Since there is no proper documentation on this any help would be appreciated.

标签: api shopify
3条回答
Juvenile、少年°
2楼-- · 2019-07-21 11:32

Yes you can!

Dont mess the people, you can do everything you want with your store.

You can do it via JavaScript, this is some related code i have used:

//update price when changing quantity
  function updatePricing() {
    jQuery('#quantity').val(jQuery('#choose-select-value option:selected').val());

      var quantity  = jQuery('#choose-select-value').val();
      var unitPriceTotal = jQuery('.product .total-price').text(); 


      var totalPrice = unitPriceTotal  * quantity;

      jQuery('.product .price').html().replace(regInput ,totalPrice);
}

This is just a way to help you go to the right place...

But please, people dont mess if you dont know something, its your store and you can do anything....

I hope this helps to you to find the way.

查看更多
在下西门庆
3楼-- · 2019-07-21 11:33

You can't directly manipulate the price of a line item in a cart. As you mentioned, the Carts API is read-only. That's all there is to it.

查看更多
相关推荐>>
4楼-- · 2019-07-21 11:38

Products have variants, and a line item has a product ID and a variant ID. A line item has a price too. And no matter how you access that item (using the Ajax API or the backend API) you cannot manipulate the price. If you want to change a price, you have to change the product's variants price. That you do with the backend API and the product or variant calls.

查看更多
登录 后发表回答