PageRenderTime 24ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/branches/3.8-development/themes/marketplace/shopping_cart_page.php

https://github.com/evadne/wp-e-commerce
PHP | 351 lines | 310 code | 36 blank | 5 comment | 47 complexity | ab0216ca9eeea85198ea7cc577134f8a 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 __('Please review your order', 'wpsc'); ?></p>
  10. <table class="productcart">
  11. <tr class="firstrow">
  12. <td class='firstcol'></td>
  13. <td><?php echo __('Product', 'wpsc'); ?>:</td>
  14. <td><?php echo __('Quantity', 'wpsc'); ?>:</td>
  15. <td><?php echo __('Price', 'wpsc'); ?>:</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 __('Update', 'wpsc'); ?>" 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 __('Remove', 'wpsc'); ?></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 __('Coupon is not valid.', 'wpsc'); ?></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 __('Update', 'wpsc') ?>' />
  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 if($_SESSION['categoryAndShippingCountryConflict'] != '') : ?>
  66. <p class='validation-error'><?php echo $_SESSION['categoryAndShippingCountryConflict']; ?></p>
  67. <?php
  68. endif;
  69. if($_SESSION['WpscGatewayErrorMessage'] != '') :
  70. ?>
  71. <p class='validation-error'><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
  72. <?php
  73. endif;
  74. ?>
  75. <?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
  76. <div id='wpsc_shopping_cart_container'>
  77. <?php if(wpsc_uses_shipping()) : ?>
  78. <h2><?php echo __('Calculate Shipping Price', 'wpsc'); ?></h2>
  79. <table class="productcart">
  80. <tr>
  81. <td colspan='5'>
  82. <?php echo __('Please choose a country below to calculate your shipping costs', 'wpsc'); ?>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td colspan='5'>
  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. <?php
  96. // Don't display shipping method if it doesn't have at least one quote
  97. if (!wpsc_have_shipping_quotes()) continue;
  98. ?>
  99. <tr><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__('- Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
  100. <?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote();
  101. ?>
  102. <tr>
  103. <td colspan='3'>
  104. <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
  105. </td>
  106. <td style='text-align:center;'>
  107. <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
  108. </td>
  109. <td style='text-align:center;'>
  110. <?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
  111. <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' />
  112. <?php else: ?>
  113. <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' />
  114. <?php wpsc_update_shipping_single_method(); ?>
  115. <?php endif; ?>
  116. </td>
  117. </tr>
  118. <?php endwhile; ?>
  119. <?php endwhile; ?>
  120. <?php wpsc_update_shipping_multiple_methods(); ?>
  121. <?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
  122. <tr>
  123. <td colspan='5'><?php echo __('Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.', 'wpsc'); ?></td>
  124. </tr>
  125. </table>
  126. </div>
  127. <?php
  128. return;
  129. endif;
  130. ?>
  131. </table>
  132. <?php endif; ?>
  133. <table class="productcart">
  134. <tr class="total_price total_tax">
  135. <td colspan="3">
  136. <?php echo wpsc_display_tax_label(true); ?>
  137. </td>
  138. <td colspan="2">
  139. <span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
  140. </td>
  141. </tr>
  142. <?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
  143. <tr class="total_price">
  144. <td colspan="3">
  145. <?php echo __('Discount', 'wpsc'); ?>
  146. </td>
  147. <td colspan="2">
  148. <span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
  149. </td>
  150. </tr>
  151. <?php endif ?>
  152. <tr class='total_price'>
  153. <td colspan='3'>
  154. <?php echo __('Total Price', 'wpsc'); ?>
  155. </td>
  156. <td colspan='2'>
  157. <span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
  158. </td>
  159. </tr>
  160. </table>
  161. <?php do_action('wpsc_before_form_of_shopping_cart'); ?>
  162. <form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
  163. <?php
  164. /**
  165. * 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.
  166. */
  167. ?>
  168. <?php if(!is_user_logged_in() && get_option('users_can_register') && get_option('require_register')) : ?>
  169. <h2><?php _e('Not yet a member?');?></h2>
  170. <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>
  171. <?php if(count($_SESSION['wpsc_checkout_user_error_messages']) > 0) : ?>
  172. <div class="login_error">
  173. <?php
  174. foreach($_SESSION['wpsc_checkout_user_error_messages'] as $user_error ) {
  175. echo $user_error."<br />\n";
  176. }
  177. $_SESSION['wpsc_checkout_user_error_messages'] = array();
  178. ?>
  179. </div>
  180. <?php endif; ?>
  181. <fieldset class='wpsc_registration_form'>
  182. <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
  183. <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
  184. <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" />
  185. </fieldset>
  186. <?php endif; ?>
  187. <h2><?php echo __('Please enter your contact details:', 'wpsc'); ?></h2>
  188. <?php/* echo __('Note, Once you press submit, you will need to have your Credit card handy.', 'wpsc'); <br /> */?>
  189. <?php echo __('Fields marked with an asterisk must be filled in.', 'wpsc'); ?>
  190. <?php
  191. if(count($_SESSION['wpsc_checkout_misc_error_messages']) > 0) {
  192. echo "<div class='login_error'>\n\r";
  193. foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ) {
  194. echo $user_error."<br />\n";
  195. }
  196. echo "</div>\n\r";
  197. }
  198. $_SESSION['wpsc_checkout_misc_error_messages'] =array();
  199. ?>
  200. <table class='wpsc_checkout_table'>
  201. <?php while (wpsc_have_checkout_items()) : wpsc_the_checkout_item(); ?>
  202. <?php if(wpsc_is_shipping_details()) : ?>
  203. <tr>
  204. <td colspan ='2'>
  205. <br />
  206. <input type='checkbox' value='true' name='shippingSameBilling' id='shippingSameBilling' />
  207. <label for='shippingSameBilling'>Shipping Address same as Billing Address?</label>
  208. </td>
  209. </tr>
  210. <?php endif; ?>
  211. <?php if(wpsc_checkout_form_is_header() == true) : ?>
  212. <tr <?php echo wpsc_the_checkout_item_error_class();?>>
  213. <td <?php if(wpsc_is_shipping_details()) echo "class='wpsc_shipping_forms'"; ?> colspan='2'>
  214. <h4>
  215. <?php echo wpsc_checkout_form_name();?>
  216. </h4>
  217. </td>
  218. </tr>
  219. <?php else: ?>
  220. <?php if((!wpsc_uses_shipping()) && $wpsc_checkout->checkout_item->unique_name == 'shippingstate'): ?>
  221. <?php else : ?>
  222. <tr <?php echo wpsc_the_checkout_item_error_class();?>>
  223. <td>
  224. <label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
  225. <?php echo wpsc_checkout_form_name();?>:
  226. </label>
  227. </td>
  228. <td>
  229. <?php echo wpsc_checkout_form_field();?>
  230. <?php if(wpsc_the_checkout_item_error() != ''): ?>
  231. <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
  232. <?php endif; ?>
  233. </td>
  234. </tr>
  235. <?php endif; ?>
  236. <?php endif; ?>
  237. <?php endwhile; ?>
  238. <?php if (get_option('display_find_us') == '1') : ?>
  239. <tr>
  240. <td>How did you find us:</td>
  241. <td>
  242. <select name='how_find_us'>
  243. <option value='Word of Mouth'>Word of mouth</option>
  244. <option value='Advertisement'>Advertising</option>
  245. <option value='Internet'>Internet</option>
  246. <option value='Customer'>Existing Customer</option>
  247. </select>
  248. </td>
  249. </tr>
  250. <?php endif; ?>
  251. <tr>
  252. <td colspan='2'>
  253. <?php //this HTML displays activated payment gateways?>
  254. <?php if(wpsc_gateway_count() > 1): // if we have more than one gateway enabled, offer the user a choice ?>
  255. <h3><?php echo __('Select a payment gateway', 'wpsc');?></h3>
  256. <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
  257. <div class="custom_gateway">
  258. <?php if(wpsc_gateway_internal_name() == 'noca'){ ?>
  259. <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>
  260. <?php }else{ ?>
  261. <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>
  262. <?php } ?>
  263. <?php if(wpsc_gateway_form_fields()): ?>
  264. <table class='<?php echo wpsc_gateway_form_field_style();?>'>
  265. <?php echo wpsc_gateway_form_fields();?>
  266. </table>
  267. <?php endif; ?>
  268. </div>
  269. <?php endwhile; ?>
  270. <?php else: // otherwise, there is no choice, stick in a hidden form ?>
  271. <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
  272. <input name='custom_gateway' value='<?php echo wpsc_gateway_internal_name();?>' type='hidden' />
  273. <?php if(wpsc_gateway_form_fields()): ?>
  274. <table>
  275. <?php echo wpsc_gateway_form_fields();?>
  276. </table>
  277. <?php endif; ?>
  278. <?php endwhile; ?>
  279. <?php endif; ?>
  280. </td>
  281. </tr>
  282. <?php if(get_option('terms_and_conditions') != '') : ?>
  283. <tr>
  284. <td colspan='2'>
  285. <input type='checkbox' value='yes' name='agree' /> <?php echo __('I agree to The ', 'wpsc');?><a class='thickbox' target='_blank' href='<?php
  286. echo get_option('siteurl')."?termsandconds=true&amp;width=360&amp;height=400'"; ?>' class='termsandconds'><?php echo __('Terms and Conditions', 'wpsc');?></a>
  287. </td>
  288. </tr>
  289. <?php endif; ?>
  290. <tr>
  291. <td colspan='2'>
  292. <?php if(get_option('terms_and_conditions') == '') : ?>
  293. <input type='hidden' value='yes' name='agree' />
  294. <?php endif; ?>
  295. <?php //exit('<pre>'.print_r($wpsc_gateway->wpsc_gateways[0]['name'], true).'</pre>');
  296. if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca'){}else{?>
  297. <input type='hidden' value='submit_checkout' name='wpsc_action' />
  298. <input type='submit' value='<?php echo __('Make Purchase', 'wpsc');?>' name='submit' class='make_purchase' />
  299. <?php }/* else: ?>
  300. <br /><strong><?php echo __('Please login or signup above to make your purchase', 'wpsc');?></strong><br />
  301. <?php echo __('If you have just registered, please check your email and login before you make your purchase', 'wpsc');?>
  302. </td>
  303. <?php endif; */?>
  304. </td>
  305. </tr>
  306. </table>
  307. </form>
  308. </div>
  309. <?php
  310. else:
  311. echo __('Oops, there is nothing in your cart.', 'wpsc') . "<a href=".get_option("product_list_url").">" . __('Please visit our shop', 'wpsc') . "</a>";
  312. endif;
  313. do_action('wpsc_bottom_of_shopping_cart');
  314. ?>