-
- 1,611 Posts
Dunno if it’s helpful, but here’s an example of what I do:
$lineItems='';
$totalAmount = $subTotal = $totalUnits = $totalWeight = $discount = $taxableTotal = $salesTax = $shippingAmount = 0;
$totalItems = count($_SESSION['basket']);
foreach($_SESSION['basket'] as $thisItem) {
$modx->setPlaceholder('shopx_item_id', $thisItem['itemid']);
$modx->setPlaceholder('shopx_item_name', $thisItem['name']);
$modx->setPlaceholder('shopx_item_code', $thisItem['code']);
$optiontext='';
foreach ($thisItem['options'] as $key=>$value) {
$optiontext.='<br />'.$key.': '.$value;
}
$modx->setPlaceholder('shopx_option_text','<span class="optiontext">'.$optiontext.'</span>');
$modx->setPlaceholder('shopx_item_unique_id', $thisItem['unique']);
$modx->setPlaceholder('shopx_item_link','[~'.$thisItem['itemid'].'~]');
$modx->setPlaceholder('shopx_item_quantity', $thisItem['quantity']);
$modx->setPlaceholder('shopx_item_price', number_format($thisItem['price'],2,'.',','));
$lineTotal = $thisItem['price'] * $thisItem['quantity'];
$modx->setPlaceholder('shopx_item_line_total', number_format($lineTotal,2,'.',','));
$lineItems .= $modx->mergePlaceholderContent($modx->mergeChunkContent($lineItemsTemplate));
$totalUnits+=$thisItem['quantity'];
$subTotal += $lineTotal;
$totalWeight+=($thisItem['points']*$thisItem['quantity']);
if($thisItem['taxable']==1) $taxableTotal+= $lineTotal;
}
$modx->setPlaceholder('shopx_line_items', $lineItems);
-
- 898 Posts
Zap,
This is a neat little code trick to reset many items to 0:
$totalAmount = $subTotal = $totalUnits = $totalWeight = $discount = $taxableTotal = $salesTax = $shippingAmount = 0;
Is there any downside to this?
-
- 1,611 Posts
Yes - you end up with nothing ;-)
-
- 388 Posts
I need some help...
some one know how to create a form to checkout with the gCart data?
every product inside a <imput name="product1" .....
with auto increment data in name="" area.
Or how is the better way to include eform to send the data to the client!
Thank you!
--
ysanmiguel.com