PageRenderTime 26ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/3.7.2/themes/default/shopping_cart_page.php

https://github.com/evadne/wp-e-commerce
PHP | 330 lines | 292 code | 34 blank | 4 comment | 42 complexity | d26ee35988236a7fe749fe5d9a28f920 MD5 | raw file
  1. <?php
  2. global $wpsc_cart, $wpdb, $wpsc_checkout, $wpsc_gateway, $wpsc_coupons;
  3. $wpsc_checkout = new wpsc_checkout();
  4. $wpsc_gateway = new wpsc_gateways();
  5. $wpsc_coupons = new wpsc_coupons($_SESSION['coupon_numbers']);
  6. //echo "<pre>".print_r($wpsc_cart,true)."</pre>";
  7. if(wpsc_cart_item_count() > 0) :
  8. ?>
  9. <p><?php echo TXT_WPSC_REVIEW_YOUR_ORDER; ?></p>
  10. <table class="productcart">
  11. <tr class="firstrow">
  12. <td class='firstcol'></td>
  13. <td><?php echo TXT_WPSC_PRODUCT; ?>:</td>
  14. <td><?php echo TXT_WPSC_QUANTITY; ?>:</td>
  15. <td><?php echo TXT_WPSC_PRICE; ?>:</td>
  16. <td></td>
  17. </tr>
  18. <?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
  19. <?php //this displays the confirm your order html ?>
  20. <tr class="product_row">
  21. <td class="firstcol"><img src='<?php echo wpsc_cart_item_image(48,48); ?>' alt='<?php echo wpsc_cart_item_name(); ?>' title='<?php echo wpsc_cart_item_name(); ?>' /></td>
  22. <td class="firstcol">
  23. <a href='<?php echo wpsc_cart_item_url();?>'><?php echo wpsc_cart_item_name(); ?></a>
  24. </td>
  25. <td>
  26. <form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
  27. <input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>"/>
  28. <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
  29. <input type="hidden" name="wpsc_update_quantity" value="true"/>
  30. <input type="submit" value="<?php echo TXT_WPSC_APPLY; ?>" name="submit"/>
  31. </form>
  32. </td>
  33. <td><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
  34. <td>
  35. <form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
  36. <input type="hidden" name="quantity" value="0"/>
  37. <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
  38. <input type="hidden" name="wpsc_update_quantity" value="true"/>
  39. <button class='remove_button' type="submit"><span><?php echo TXT_WPSC_REMOVE; ?></span></button>
  40. </form>
  41. </td>
  42. </tr>
  43. <?php endwhile; ?>
  44. <?php //this HTML displays coupons if there are any active coupons to use ?>
  45. <?php //exit('<pre>'.print_r($wpsc_coupons, true).'</pre>'); ?>
  46. <?php if(wpsc_uses_coupons()): ?>
  47. <?php if(wpsc_coupons_error()): ?>
  48. <tr><td><?php echo TXT_WPSC_COUPONSINVALID; ?></td></tr>
  49. <?php endif; ?>
  50. <tr>
  51. <td colspan="2"><?php _e('Enter your coupon number'); ?> :</td>
  52. <td colspan="3" align='left'>
  53. <form method='post' action="<?php echo get_option('shopping_cart_url'); ?>">
  54. <input type='text' name='coupon_num' id='coupon_num' value='<?php echo $wpsc_cart->coupons_name; ?>' />
  55. <input type='submit' value='<?php echo TXT_WPSC_APPLY ?>' />
  56. </form>
  57. </td>
  58. </tr>
  59. <?php endif; ?>
  60. </table>
  61. <?php //this HTML dispalys the calculate your order HTML ?>
  62. <?php if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm'): ?>
  63. <p class='validation-error'><?php echo $_SESSION['nocamsg']; ?></p>
  64. <?php endif; ?>
  65. <?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
  66. <div id='wpsc_shopping_cart_container'>
  67. <?php if(wpsc_uses_shipping()) : ?>
  68. <h2><?php echo TXT_WPSC_SHIPPING_COUNTRY; ?></h2>
  69. <table class="productcart">
  70. <tr>
  71. <td colspan='5'>
  72. <?php echo TXT_WPSC_SHIPPING_DETAIL; ?>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td colspan='5'>
  77. <?php if($_SESSION['categoryAndShippingCountryConflict'] != '') : ?>
  78. <p class='validation-error'><?php echo $_SESSION['categoryAndShippingCountryConflict']; ?></p>
  79. <?php
  80. endif;
  81. if($_SESSION['WpscGatewayErrorMessage'] != '') :
  82. ?>
  83. <p class='validation-error'><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
  84. <?php
  85. endif;
  86. ?>
  87. <form name='change_country' id='change_country' action='' method='post'>
  88. <?php echo wpsc_shipping_country_list();?>
  89. <input type='hidden' name='wpsc_update_location' value='true' />
  90. <input type='submit' name='wpsc_submit_zipcode' value='Calculate' />
  91. </form>
  92. </td>
  93. </tr>
  94. <?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
  95. <tr><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().TXT_WPSC_CHOOSE_A_SHIPPING_RATE; ?> </td></tr>
  96. <?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote();
  97. ?>
  98. <tr>
  99. <td colspan='3'>
  100. <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
  101. </td>
  102. <td style='text-align:center;'>
  103. <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
  104. </td>
  105. <td style='text-align:center;'>
  106. <?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
  107. <input type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' <?php echo wpsc_shipping_quote_selected_state(); ?> onclick='switchmethod("<?php echo wpsc_shipping_quote_name(); ?>", "<?php echo wpsc_shipping_method_internal_name(); ?>")' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
  108. <?php else: ?>
  109. <input <?php echo wpsc_shipping_quote_selected_state(); ?> disabled='disabled' type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
  110. <?php wpsc_update_shipping_single_method(); ?>
  111. <?php endif; ?>
  112. </td>
  113. </tr>
  114. <?php endwhile; ?>
  115. <?php endwhile; ?>
  116. <?php wpsc_update_shipping_multiple_methods(); ?>
  117. </table>
  118. <?php endif; ?>
  119. <table class="productcart">
  120. <tr class="total_price total_tax">
  121. <td colspan="3">
  122. <?php echo TXT_WPSC_TAX; ?>
  123. </td>
  124. <td colspan="2">
  125. <span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
  126. </td>
  127. </tr>
  128. <?php if(wpsc_uses_coupons() && (wpsc_coupon_amount() != 0)): ?>
  129. <tr class="total_price">
  130. <td colspan="3">
  131. <?php echo TXT_WPSC_COUPONS; ?>
  132. </td>
  133. <td colspan="2">
  134. <span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
  135. </td>
  136. <?php endif ?>
  137. </tr>
  138. <tr class='total_price'>
  139. <td colspan='3'>
  140. <?php echo TXT_WPSC_TOTALPRICE; ?>
  141. </td>
  142. <td colspan='2'>
  143. <span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
  144. </td>
  145. </tr>
  146. </table>
  147. <?php do_action('wpsc_before_form_of_shopping_cart'); ?>
  148. <form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
  149. <?php
  150. /**
  151. * Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
  152. */
  153. ?>
  154. <?php if(!is_user_logged_in() && get_option('users_can_register') && get_option('require_register')) : ?>
  155. <h2><?php _e('Not yet a member?');?></h2>
  156. <p><?php _e('In order to buy from us, you\'ll need an account. Joining is free and easy. All you need is a username, password and valid email address.');?></p>
  157. <?php if(count($_SESSION['wpsc_checkout_user_error_messages']) > 0) : ?>
  158. <div class="login_error">
  159. <?php
  160. foreach($_SESSION['wpsc_checkout_user_error_messages'] as $user_error ) {
  161. echo $user_error."<br />\n";
  162. }
  163. $_SESSION['wpsc_checkout_user_error_messages'] = array();
  164. ?>
  165. </div>
  166. <?php endif; ?>
  167. <fieldset class='wpsc_registration_form'>
  168. <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
  169. <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
  170. <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
  171. </fieldset>
  172. <?php endif; ?>
  173. <h2><?php echo TXT_WPSC_CONTACTDETAILS; ?></h2>
  174. <?php/* echo TXT_WPSC_CREDITCARDHANDY; <br /> */?>
  175. <?php echo TXT_WPSC_ASTERISK; ?>
  176. <?php
  177. if(count($_SESSION['wpsc_checkout_misc_error_messages']) > 0) {
  178. echo "<div class='login_error'>\n\r";
  179. foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ) {
  180. echo $user_error."<br />\n";
  181. }
  182. echo "</div>\n\r";
  183. }
  184. $_SESSION['wpsc_checkout_misc_error_messages'] =array();
  185. ?>
  186. <table class='wpsc_checkout_table'>
  187. <?php while (wpsc_have_checkout_items()) : wpsc_the_checkout_item(); ?>
  188. <?php if(wpsc_is_shipping_details()) : ?>
  189. <tr>
  190. <td colspan ='2'>
  191. <br />
  192. <input type='checkbox' value='true' name='shippingSameBilling' id='shippingSameBilling' />
  193. <label for='shippingSameBilling'>Shipping Address same as Billing Address?</label>
  194. </td>
  195. </tr>
  196. <?php endif; ?>
  197. <tr <?php echo wpsc_shipping_details(); ?><?php echo wpsc_the_checkout_item_error_class();?>>
  198. <?php if(wpsc_checkout_form_is_header() == true) : ?>
  199. <td <?php if(wpsc_is_shipping_details()) echo "class='wpsc_shipping_forms'"; ?> colspan='2'>
  200. <h4>
  201. <?php echo wpsc_checkout_form_name();?>
  202. </h4>
  203. </td>
  204. <?php else: ?>
  205. <td>
  206. <label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
  207. <?php echo wpsc_checkout_form_name();?>:
  208. </label>
  209. </td>
  210. <td>
  211. <?php echo wpsc_checkout_form_field();?>
  212. <?php if(wpsc_the_checkout_item_error() != ''): ?>
  213. <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
  214. <?php endif; ?>
  215. </td>
  216. <?php endif; ?>
  217. </tr>
  218. <?php endwhile; ?>
  219. <?php if (get_option('display_find_us') == '1') : ?>
  220. <tr>
  221. <td>How did you find us:</td>
  222. <td>
  223. <select name='how_find_us'>
  224. <option value='Word of Mouth'>Word of mouth</option>
  225. <option value='Advertisement'>Advertising</option>
  226. <option value='Internet'>Internet</option>
  227. <option value='Customer'>Existing Customer</option>
  228. </select>
  229. </td>
  230. </tr>
  231. <?php endif; ?>
  232. <tr>
  233. <td colspan='2'>
  234. <?php //this HTML displays activated payment gateways?>
  235. <?php if(wpsc_gateway_count() > 1): // if we have more than one gateway enabled, offer the user a choice ?>
  236. <h3><?php echo TXT_WPSC_SELECTGATEWAY;?></h3>
  237. <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
  238. <div class="custom_gateway">
  239. <?php if(wpsc_gateway_internal_name() == 'noca'){ ?>
  240. <label><input type="radio" id='noca_gateway' value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
  241. <?php }else{ ?>
  242. <label><input type="radio" value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
  243. <?php } ?>
  244. <?php if(wpsc_gateway_form_fields()): ?>
  245. <table class='<?php echo wpsc_gateway_form_field_style();?>'>
  246. <?php echo wpsc_gateway_form_fields();?>
  247. </table>
  248. <?php endif; ?>
  249. </div>
  250. <?php endwhile; ?>
  251. <?php else: // otherwise, there is no choice, stick in a hidden form ?>
  252. <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
  253. <input name='custom_gateway' value='<?php echo wpsc_gateway_internal_name();?>' type='hidden' />
  254. <?php if(wpsc_gateway_form_fields()): ?>
  255. <table>
  256. <?php echo wpsc_gateway_form_fields();?>
  257. </table>
  258. <?php endif; ?>
  259. <?php endwhile; ?>
  260. <?php endif; ?>
  261. </td>
  262. </tr>
  263. <?php if(get_option('terms_and_conditions') != '') : ?>
  264. <tr>
  265. <td colspan='2'>
  266. <input type='checkbox' value='yes' name='agree' /> <?php echo TXT_WPSC_TERMS1;?><a class='thickbox' target='_blank' href='<?php
  267. echo get_option('siteurl')."?termsandconds=true&amp;width=360&amp;height=400'"; ?>' class='termsandconds'><?php echo TXT_WPSC_TERMS2;?></a>
  268. </td>
  269. </tr>
  270. <?php endif; ?>
  271. <tr>
  272. <td colspan='2'>
  273. <?php if(get_option('terms_and_conditions') == '') : ?>
  274. <input type='hidden' value='yes' name='agree' />
  275. <?php endif; ?>
  276. <?php //exit('<pre>'.print_r($wpsc_gateway->wpsc_gateways[0]['name'], true).'</pre>');
  277. if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca'){}else{?>
  278. <input type='hidden' value='submit_checkout' name='wpsc_action' />
  279. <input type='submit' value='<?php echo TXT_WPSC_MAKEPURCHASE;?>' name='submit' class='make_purchase' />
  280. <?php }/* else: ?>
  281. <br /><strong><?php echo TXT_WPSC_PLEASE_LOGIN;?></strong><br />
  282. <?php echo TXT_WPSC_IF_JUST_REGISTERED;?>
  283. </td>
  284. <?php endif; */?>
  285. </td>
  286. </tr>
  287. </table>
  288. </form>
  289. </div>
  290. <?php
  291. else:
  292. echo TXT_WPSC_BUYPRODUCTS;
  293. endif;
  294. do_action('wpsc_bottom_of_shopping_cart');
  295. ?>