Advertisement
chandlerswatch

excluding shipping from the second item

Oct 21st, 2011
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. From the shoppingcart_functions.php file:
  2. 'function get_shopping_cart() {
  3. global $wpdb, $_POST;
  4.  
  5. update_shopping_cart();
  6.  
  7. ?>
  8. <div class="ShoppingCartTable">
  9. <form name="shopping_cart" action="<?php the_permalink(get_the_ID()) ?>" method="post">
  10. <input type="hidden" name="updateshoppingcart" value="1" />
  11. <table>
  12. <thead>
  13. <tr>
  14. <th class="first"><?php echo translate("Product"); ?></th>
  15. <th class="QtyColumn"><?php echo translate("Quantity"); ?></th>
  16. <th></th>
  17. <th class="PriceColumn"><?php echo translate("Item price"); ?></th>
  18. <th class="TotalPriceColumn last"><?php echo translate("Total price"); ?></th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. <?php
  23. $sc_info = $wpdb->get_results("SELECT * FROM es_sc WHERE SessionID = '".session_id()."'");
  24. $productexists = 0;
  25. $grandtotalprice = 0;
  26. $grandtotalshipping = 0;
  27. $grandtotal = 0;
  28. $itemnr = 1;
  29. foreach($sc_info as $sc) {
  30.  
  31. $prodname = $wpdb->get_var($wpdb->prepare("SELECT post_title FROM ".$wpdb->prefix."posts WHERE ID = ".$sc->ProdID));
  32. $prodprice = $wpdb->get_var($wpdb->prepare("SELECT Price FROM es_products WHERE PostID = ".$sc->ProdID));
  33. $prodshipping = $wpdb->get_var($wpdb->prepare("SELECT ShippingCost FROM es_products WHERE PostID = ".$sc->ProdID));
  34. $totalprice = $prodprice*$sc->Qty;
  35. $totalshipping = $prodshipping;
  36. $grandtotalprice = $grandtotalprice+$totalprice;
  37. $grandtotalshipping = $grandtotalshipping+$totalshipping;
  38.  
  39. if ($itemnr%2 == 1) {
  40. ?>
  41. <tr class="odd">
  42. <?php
  43. } else {
  44. ?>
  45. <tr class="even">
  46. <?php } ?>
  47. <td><?php echo '<a href="'.get_permalink($sc->ProdID).'">'.$prodname.'</a>'; ?></td>
  48. <td class="QtyColumn"><input type="text" class="Qty" value="<?php echo $sc->Qty; ?>" name="Qty_<?php echo $sc->ProdID; ?>" /></td>
  49. <td class="PriceText"><?php echo translate("Product price"); ?><br/><?php echo translate("Shipping cost"); ?></td>
  50. <td class="PriceColumn"><?php echo get_currency().number_format($prodprice,2, '.', ','); ?><br/><?php echo get_currency().number_format($prodshipping,2, '.', ','); ?></td>
  51. <td class="TotalPriceColumn"><?php echo get_currency().number_format($totalprice,2, '.', ','); ?><br/><?php echo get_currency().number_format($totalshipping,2, '.', ','); ?></td>
  52. </tr>
  53. <input type="hidden" name="item_name_<?php echo $itemnr; ?>" value="<?php echo $prodname; ?>" />
  54. <input type="hidden" name="amount_<?php echo $itemnr; ?>" value="<?php echo get_currency().number_format($prodprice,2, '.', ','); ?>" />
  55. <input type="hidden" name="quantity_<?php echo $itemnr; ?>" value="<?php echo $sc->Qty; ?>" />
  56. <input type="hidden" name="shipping_<?php echo $itemnr; ?>" value="<?php echo get_currency().number_format($totalshipping,2, '.', ','); ?>" />
  57.  
  58.  
  59. <?php
  60. $itemnr++;
  61. }
  62.  
  63. $grandtotal = $grandtotalprice+$grandtotalshipping;
  64. ?>
  65.  
  66. </tbody>
  67. </form>'
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement