Skip to main content

Some context to this is once a deal stage reaches closed won within HubSpot im looking to pull all of the information and eventually create a draft order within Shopify with the collected deal information.

 

I seem to have hit a stumbling block at the final part of this where I am trying to calculate the discount that needs to be applied to the draft order.

I begin gathering all of the hubspot data - minus the line items, which sits within the beginning of a loop to append each line of data I need from the line item information.

There is then a loop for each line item found whilst pulling in the respective information from Shopify that is needed in order to create the draft, each line of data is then appended ready for release post loop.

The loop is ends post appending of data, where a calculation with HubSpot properties is created to find the deal value +VAT

This is where the complications really start and where I am stuck.

I now need to calculate what the price would be on Shopify (as the deal total within Hubspot will always be cheaper than the Shopify total price - due to customers and volume).  

The calculation below is the quantity of each item sold x Shopify Price - which returns an expected result for each line item.
 

 

NOW I need to Sum the results from the above to return a single figure as the output.  I am finding that due to the figures being within an array is making that pretty complicated and returning errors.  I have tried formatting these values to text, as well as line items, but I am still returning errors.

 

Any suggestions/reformatting/ideas are very welcomed!

This result will then be used to determine the difference between the Total Deal Value and the alternative Shopify Total - which ultimately will deliver a single value which will be inputted as a fixed discount within the draft order of Shopify.

Hi ​@Nic Biffen,

 

Welcome to the Community.

 

You're trying to sum line item prices from a HubSpot deal and compare them to Shopify to calculate a discount, but the prices are in an array. To troubleshoot this, process and sum the values using a 'Code by Zapier' action with JavaScript. Once totaled, subtract it from the deal value to determine the discount. If needed, seek Zapier Expert's assistance with implementation.

 

I hope this helps. Let me know if you have any other questions or need further assistance.