We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33372
    • 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);
      "Things are not what they appear to be; nor are they otherwise." - Buddha

      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
      • 34017
      • 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?
        Chuck the Trukk
        ProWebscape.com :: Nashville-WebDesign.com
        - - - - - - - -
        What are TV's? Here's some info below.
        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
        • 33372
        • 1,611 Posts
        Yes - you end up with nothing ;-)
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 33238
          • 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