Skip to content

Commit 4a7544f

Browse files
authored
Updated handling of Shopify Price & Compare Price
Updated logic: Shopify “Compare Price” is the default Base Price in CSV, if it is empty, then Shopify “Price” is the Base Price. If “Compare Price” is empty, & only “Price” exists, the Base Price in the CSV is that value and Sale Price is null. If “Compare Price” is greater than the “Price”, then Base Price in the CSV is “Compare Price” and the Sale Price in the CSV is “Price”. If “Compare Price” and “Price” are equal, the Base Price will inherit the equal value & Sale Price is null.
1 parent 440b2bd commit 4a7544f

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

shopify.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,33 @@ def get_product_row(i,metafields):
365365
if 'weight_unit' in k:
366366
unit_of_weight = k['weight_unit']
367367
weight = k['weight']
368-
return [ k['price'] if 'price' in k else '', k['compare_at_price'] if 'compare_at_price' in k else (k['price'] if 'price' in k else '') , quantity , format_unit_weight(unit_of_weight) , weight if weight else '1' , "IN" , "3" , "3" , "3" ,seo_title,seo_desc ]
368+
base_price = k['compare_at_price'] if 'compare_at_price' in k else ''
369+
if(base_price == '' or base_price==None): base_price = k['price'] if 'price' in k else ''
370+
sale_price = k['price'] if base_price!='' else ''
371+
try:
372+
if(base_price != '' and sale_price != '' and float(base_price) < float(sale_price)):
373+
tmp_var = sale_price
374+
sale_price = base_price
375+
base_price = tmp_var
376+
except Exception as e:
377+
pass
378+
if sale_price == base_price:
379+
sale_price = ''
380+
return [ base_price, sale_price , quantity , format_unit_weight(unit_of_weight) , weight if weight else '1' , "IN" , "3" , "3" , "3" ,seo_title,seo_desc ]
369381
else:
370-
return [ i['price'] if 'price' in i else '', i['compare_at_price'] if 'compare_at_price' in i else (i['price'] if 'price' in i else '') , quantity , format_unit_weight(unit_of_weight) , weight if weight else '1' , "IN" , "3" , "3" , "3" ,seo_title,seo_desc ]
382+
base_price = i['compare_at_price'] if 'compare_at_price' in i else ''
383+
if(base_price == '' or base_price==None): base_price = i['price'] if 'price' in i else ''
384+
sale_price = i['price'] if base_price!='' else ''
385+
try:
386+
if(base_price != '' and sale_price != '' and float(base_price) < float(sale_price)):
387+
tmp_var = sale_price
388+
sale_price = base_price
389+
base_price = tmp_var
390+
except Exception as e:
391+
pass
392+
if sale_price == base_price:
393+
sale_price = ''
394+
return [ base_price, sale_price , quantity , format_unit_weight(unit_of_weight) , weight if weight else '1' , "IN" , "3" , "3" , "3" ,seo_title,seo_desc ]
371395

372396
if __name__ == '__main__':
373397
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)