Jump to content

Get discount per item sold through API

Go to solution Solved by paul2009,

Recommended Posts

Hi All,

We have integration built that is working well and uses the Orders API to populate sales order lines in our back end system. We use the SKU to map the item from Squarespace to our items in our back end system and through the Orders API get the QTY and the SKU of the item sold.

However I am having issues getting the discount to populate for each sale line. I.e. if we have a discount applied to one product in squarespace how can I get the discount that was related to that item only and use it to populate the discount field for the sale line in our back end system. 

The Orders API shows the discount lines separate to the line items so we can get the total discount and apply it to the whole invoice but we dont want any discount applied to items that weren't discounted.

The Transaction API has the discount per salesLineItems but the only id is the the sales line item id which doesn't match back to anything on the Orders API.

Hope this is clear what we are trying to do and equally hoping there is method to do this.

Any help much appreciated.

Edited by harriette
Link to comment
  • Solution
14 hours ago, harriette said:

I am having issues getting the discount to populate for each sale line. I.e. if we have a discount applied to one product in squarespace how can I get the discount that was related to that item only and use it to populate the discount field for the sale line in our back end system. 

In Squarespace you can create sale pricing for individual products, as well as discounts that apply to entire orders, individual products and product categories.

Sale Pricing

If you're referring to the discount that is applied to a product when you place the product 'on sale' and populate the 'sale price' field, this discount is already applied to the "unitPricePaid" field. You cannot retrieve the original price from Squarespace so you'd need to use the value from your backend system to calculate any discount that was applied.

Commerce Discounts

If you're referring to promotions that you set in Commerce > Discounts, these are applied to the overall order and are not reflected in the price of individual line items, even if the conditions required the purchase of a specific product. These discounts are shown in "discountLines". Squarespace doesn't provide a way of matching these discounts to individual products that were purchased so if you want to calculate these, you'll need to write your own logic (in the integration you have built) to calculate these for each discount/ promotion.

Improve your online store with our extensions.
About: Squarespace Circle Leader since 2017. I value honesty, transparency, appreciation and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™.
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Buy me a coffee

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.