ordering-ui-react-native 0.24.10 → 0.24.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.24.10",
3
+ "version": "0.24.11",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -72,18 +72,20 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
72
72
  const parseOptions = typeof productInfo().options === 'string' ? JSON.parse(productInfo().options) : productInfo().options
73
73
 
74
74
  const getProductPrice = (product: any) => {
75
- let subOptionPrice = 0;
76
- if (product?.options?.length > 0 && product?.options[0]?.suboptions?.length > 0) {
77
- for (const option of product?.options) {
78
- for (const suboption of option?.suboptions) {
79
- subOptionPrice += suboption.quantity * suboption.price;
75
+ let subOptionPrice = 0
76
+ if (Array.isArray(product?.options)) {
77
+ if (product.options?.length > 0) {
78
+ for (const option of product.options) {
79
+ for (const suboption of option.suboptions) {
80
+ subOptionPrice += suboption.quantity * ((['left', 'right'].includes(suboption.position)) ? (suboption.half_price ?? suboption.price) : suboption.price)
81
+ }
80
82
  }
81
83
  }
82
84
  }
83
85
 
84
- const price = product.quantity * (product.price + subOptionPrice);
85
- return parseFloat(price.toFixed(2));
86
- };
86
+ const price = product.quantity * (product.price + subOptionPrice)
87
+ return parseFloat(price.toFixed(2))
88
+ }
87
89
 
88
90
  const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
89
91
  if (name !== 'No') {