{{vtScript}} {{vtPromo}} {{vtInclude: includes/initialize.html}} {{vtIf: {vtGetValue:q} .lt. 1 }} {{vtSet: NewCart="" }} {{vtRepeat: {vtGet:Cart} }} {{vtIf: {vtItem:image} .eq. {vtId} .and. {vtItem:product} .eq. {vtGetValue:item} }} {{vtSet: Result[itemId] = "{vtItem:id}" }} {{vtElse}} {{vtSet: NewCart[]="{vtItem}" }} {{vtEndIf}} {{vtEndRepeat}} {{vtSet: Cart = "{vtGet:NewCart}"}} {{vtElse}} {{vtInclude: includes/func_add_to_cart.html}} {{vtCall: -name="add_to_cart", Image="{vtId}", Product="{vtGetValue:item}", Amount="{vtGetValue:q}", Mode="replace" }} {{vtSet: Result[itemId] = "{vtResult}" }} {{vtEndIf}} {{vtCalc: discountCart() }} {{vtIf: {vtUser:id} .gt. 100 .and. {vtUser:accountType} .neq. 2 }} {{vtDo: -act="update", -obj="{vtUser:id}", Cart="{vtGet:Cart}"}} {{vtElse}} {{vtDo: -act="updateSession", Cart="{vtGet:Cart}"}} {{vtEndIf}} {{vtRepeat: {vtGet:Cart} }} {{vtIf: {vtItem:image} .eq. {vtId} .and. {vtItem:product} .eq. {vtGetValue:item} }} {{vtSet: Result[itemPrice] = "{vtItem:price|num-en:2}" }} {{vtSet: Result[itemNetprice] = "{vtItem:netprice|num-en:2}" }} {{vtEndIf}} {{vtSet: Item[id] = "{vtItem:id}" }} {{vtSet: Item[quantity] = "{vtItem:quantity}" }} {{vtSet: Item[price] = "{vtItem:price|num-en:2}" }} {{vtSet: Item[netprice] = "{vtItem:netprice|num-en:2}" }} {{vtSet: Item[total] = "{vtItem:total|num-en:2}" }} {{vtSet: Item[nettotal] = "{vtItem:nettotal|num-en:2}" }} {{vtSet: CartItems[] = "{vtGet:Item}" }} {{vtEndRepeat}} {{vtIf: {vtGlobal:pxtcVatHandling} .bw. excl}} {{vtCalc: evalList('{vtGet:Cart,escaped}','nettotal','sum') }} {{vtSet: Result[cartValue]="{vtResult|num-en:2}" }} {{vtElse}} {{vtCalc: evalList('{vtGet:Cart,escaped}','total','sum') }} {{vtSet: Result[cartValue]="{vtResult|num-en:2}" }} {{vtEndIf}} {{vtSet: Result[imageId] = "{vtId}" }} {{vtSet: Result[productId] = "{vtGetValue:item}" }} {{vtSet: Result[itemCount] = "{vtGetValue:q}" }} {{vtCalc: countList('{vtGet:Cart}') }} {{vtSet: Result[cartCount] = "{vtResult}" }} {{vtCalc: isImageInCart( '{vtId}' ) }} {{vtSet: Result[inCartStatus] = "{vtResult}" }} {{vtHeader: Content-Type: application/json}} {{vtEndScript}}