Shopify API CARTS - Changing line_item line_price for price Override

試著忘記壹切 提交于 2019-12-11 02:56:39

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/12752654/shopify-api-carts-changing-line-item-line-price-for-price-override

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!