/template/paypal-review-order.php

  1. <?php 
  2. /** 
  3. * Review Order 
  4. */ 
  5.  
  6. global $woocommerce; 
  7. $checked = get_option('woocommerce_enable_guest_checkout'); 
  8. $checkout_form_data = maybe_unserialize(WC()->session->checkout_form); 
  9. $hide_button = false; 
  10. ### After PayPal payment method confirmation, user is redirected back to this page with token and Payer ID ### 
  11.  
  12. $frm_act = add_query_arg(array( 'pp_action' => 'payaction')); 
  13. $is_paypal_express = true; 
  14. $result = unserialize(WC()->session->RESULT); 
  15. $email = ( isset($_POST['email']) && !empty($_POST['email'])) ? $_POST['email'] : (isset($result['EMAIL']) && !empty($result['EMAIL'])) ? $result['EMAIL'] : ''; 
  16. if (!isset(WC()->session->TOKEN)) { 
  17. $ms = sprintf(__('Sorry, your session has expired. <a href=%s>Return to homepage →</a>', 'paypal-for-woocommerce'), '"' . home_url() . '"'); 
  18. $ec_confirm_message = apply_filters('angelleye_ec_confirm_message', $ms); 
  19. wc_add_notice($ec_confirm_message, "error"); 
  20. $hide_button = true; 
  21. //Add hook to show login form or not 
  22. $show_login = apply_filters('paypal-for-woocommerce-show-login', $is_paypal_express && !is_user_logged_in() && $checked==="no" ); 
  23.  
  24. //Add hook to show create account form 
  25. $show_act = apply_filters('paypal-for-woocommerce-show-login', $is_paypal_express && !is_user_logged_in() && $checked==="yes" && empty($checkout_form_data['billing_address_1'])); 
  26.  
  27. ?> 
  28.  
  29. <?php do_action( 'angelleye_review_order_before_checkout_form' );?> 
  30.  
  31. <form class="angelleye_checkout" method="POST" action="<?php echo $frm_act;?>"> 
  32. <div class="wp_notice_own"></div> 
  33. <?php wc_print_notices();?> 
  34.  
  35. <?php do_action( 'angelleye_review_order_before_cart_contents' );?> 
  36.  
  37. <div id="paypalexpress_order_review"> 
  38. <?php woocommerce_order_review();?> 
  39. </div> 
  40.  
  41. <?php do_action( 'angelleye_review_order_after_cart_contents' );?> 
  42.  
  43. <?php if ( WC()->cart->needs_shipping() ) : ?> 
  44.  
  45. <?php do_action( 'angelleye_review_order_before_customer_details' );?> 
  46.  
  47. <div class="title"> 
  48. <h2><?php _e( 'Customer details', 'paypal-for-woocommerce' ); ?></h2> 
  49. </div> 
  50.  
  51. <div class="col2-set addresses"> 
  52.  
  53. <div class="col-1"> 
  54.  
  55. <div class="title"> 
  56. <h3><?php _e( 'Shipping Address', 'paypal-for-woocommerce' ); ?></h3> 
  57. </div> 
  58. <div class="address"> 
  59. <p> 
  60. <?php 
  61. // Formatted Addresses 
  62. $address = array( 
  63. 'first_name' => WC()->customer->shiptoname,  
  64. 'company' => WC()->customer->company,  
  65. 'address_1' => WC()->customer->shipping_address_1,  
  66. 'address_2' => WC()->customer->shipping_address_2,  
  67. 'city' => WC()->customer->shipping_city,  
  68. 'state' => WC()->customer->shipping_state,  
  69. 'postcode' => WC()->customer->shipping_postcode,  
  70. 'country' => WC()->customer->shipping_country 
  71. ) ; 
  72.  
  73. echo WC()->countries->get_formatted_address( $address ); 
  74. ?> 
  75. </p> 
  76. </div> 
  77.  
  78. </div><!-- /.col-1 --> 
  79. <div class="col-2"> 
  80. <?php  
  81. $woocommerce_paypal_express_settings = maybe_unserialize(get_option('woocommerce_paypal_express_settings')); 
  82. // Formatted Addresses 
  83. $user_submit_form = maybe_unserialize(WC()->session->checkout_form); 
  84.  
  85. if( (isset($user_submit_form) && !empty($user_submit_form)) && is_array($user_submit_form) ) { 
  86. if( isset($user_submit_form['ship_to_different_address']) && $user_submit_form['ship_to_different_address'] == true ) { 
  87. $billing_address = array( 
  88. 'first_name' => $user_submit_form['billing_first_name'],  
  89. 'last_name' => $user_submit_form['billing_last_name'],  
  90. 'company' => $user_submit_form['billing_company'],  
  91. 'address_1' => $user_submit_form['billing_address_1'],  
  92. 'address_2' => $user_submit_form['billing_address_2'],  
  93. 'city' => $user_submit_form['billing_city'],  
  94. 'state' => $user_submit_form['billing_state'],  
  95. 'postcode' => $user_submit_form['billing_postcode'],  
  96. 'country' => $user_submit_form['billing_country'] 
  97. ) ; 
  98. } else { 
  99.  
  100. $billing_address = array( 
  101. 'first_name' => WC()->customer->firstname. ' '. WC()->customer->lastname,  
  102. 'company' => WC()->customer->company,  
  103. 'address_1' => WC()->customer->get_address(),  
  104. 'address_2' => WC()->customer->get_address_2(),  
  105. 'city' => WC()->customer->get_city(),  
  106. 'state' => WC()->customer->get_state(),  
  107. 'postcode' => WC()->customer->get_postcode(),  
  108. 'country' => WC()->customer->get_country() 
  109. ) ; 
  110.  
  111. if( isset($billing_address) && !empty($billing_address) ) : 
  112. ?> 
  113.  
  114.  
  115. <div class="title"> 
  116. <h3><?php _e( 'Billing Address', 'paypal-for-woocommerce' ); ?></h3> 
  117. </div> 
  118. <div class="address"> 
  119. <p> 
  120.  
  121. <?php  
  122. echo WC()->countries->get_formatted_address( $billing_address ); 
  123.  
  124. ?> 
  125. </p> 
  126. </div> 
  127.  
  128.  
  129. <?php endif; ?> 
  130. </div><!-- /.col-2 --> 
  131. </div><!-- /.col2-set --> 
  132.  
  133. <?php do_action( 'angelleye_review_order_after_customer_details' );?> 
  134. <?php endif; ?> 
  135. <?php do_action( 'woocommerce_after_order_notes', WC()->checkout() ); ?> 
  136. <?php if ( $show_act ): ?> 
  137. <script type="text/javascript"> 
  138. jQuery(document).ready(function() { 
  139. jQuery(".chkcreate_act").click(function() { 
  140. var ischecked_act = jQuery('.chkcreate_act').is(':checked') ; 
  141.  
  142. if (ischecked_act == false) { 
  143. jQuery('.create_account_child').toggle(); 
  144. }else if(ischecked_act == true) { 
  145. jQuery('.create_account_child').toggle(); 
  146.  
  147. }); 
  148. }); 
  149. </script> 
  150.  
  151. <?php do_action( 'angelleye_review_order_before_create_account' );?> 
  152.  
  153. <div class="create-account" class="div_create_act" > 
  154. <p class="form-row form-row-wide create-account div_create_act_para" style="cursor:pointer;"> 
  155. <input class="input-checkbox chkcreate_act" id="createaccount" type="checkbox" name="createaccount" value="1"> 
  156. <label for="createaccount" style="cursor:pointer;" class="checkbox lbl_chkcreate_act"><?php echo __('Create an account?', 'paypal-for-woocommerce');?></label> 
  157. </p> 
  158. <div class="create_account_child" style="display:none;"> 
  159. <p><?php echo __('Create an account by entering the information below. If you are a returning customer please login at the top of the page.', 'paypal-for-woocommerce');?></p> 
  160. <p class="form-row validate-required"> 
  161. <label for="paypalexpress_order_review_email">Email:<span class="required">*</span></label> 
  162. <input style="width: 100%;" type="email" name="email" id="paypalexpress_order_review_email" value="<?php echo $email; ?>" /> 
  163. </p> 
  164. <p class="form-row validate-required woocommerce-validated form-row-last" id="account_password_field"> 
  165. <label for="account_password" class=""><?php echo __('Account password', 'paypal-for-woocommerce');?><abbr class="required" title="required">*</abbr> 
  166. </label> 
  167. <input type="password" class="input-text" placeholder="Password" value="" name="create_act"/> 
  168. </p> 
  169.  
  170. <div class="clear"></div> 
  171. </div> 
  172. </div> 
  173.  
  174. <?php do_action( 'angelleye_review_order_after_create_account' );?> 
  175.  
  176. <?php endif;?> 
  177. <?php if ( $show_login ): ?> 
  178. </form> 
  179. <style type="text/css"> 
  180.  
  181. .woocommerce #content p.form-row input.button,  
  182. .woocommerce #respond p.form-row input#submit,  
  183. .woocommerce p.form-row a.button,  
  184. .woocommerce p.form-row button.button,  
  185. .woocommerce p.form-row input.button,  
  186. .woocommerce-page p.form-row #content input.button,  
  187. .woocommerce-page p.form-row #respond input#submit,  
  188. .woocommerce-page p.form-row a.button,  
  189. .woocommerce-page p.form-row button.button,  
  190. .woocommerce-page p.form-row input.button{ 
  191. display: block !important; 
  192. </style> 
  193.  
  194. <?php do_action( 'angelleye_review_order_before_login_create_account' );?> 
  195.  
  196. <div class="title"> 
  197. <h2><?php _e( 'Login', 'paypal-for-woocommerce' ); ?></h2> 
  198. </div> 
  199. <form name="" action="" method="post"> 
  200. <?php 
  201.  
  202. woocommerce_login_form( 
  203. array( 
  204. 'message' => 'Please login or create an account to complete your order.',  
  205. 'redirect' => AngellEYE_Gateway_Paypal::curPageURL(),  
  206. 'hidden' => true 
  207. ); 
  208. ?> 
  209. </form> 
  210. <div class="title"> 
  211. <h2><?php _e( 'Create A New Account', 'paypal-for-woocommerce' ); ?></h2> 
  212. </div> 
  213. <form action="<?php echo add_query_arg(array( 'pp_action' => 'revieworder'));?>" method="post"> 
  214. <p class="form-row form-row-first"> 
  215. <label for="paypalexpress_order_review_username">Username:<span class="required">*</span></label> 
  216. <input style="width: 100%;" type="text" name="username" id="paypalexpress_order_review_username" value="<?php echo @$_POST['username']; ?>" /> 
  217. </p> 
  218. <p class="form-row form-row-last"> 
  219. <label for="paypalexpress_order_review_email">Email:<span class="required">*</span></label> 
  220. <input style="width: 100%;" type="email" name="email" id="paypalexpress_order_review_email" value="<?php echo $email; ?>" /> 
  221. </p> 
  222. <div class="clear"></div> 
  223. <p class="form-row form-row-first"> 
  224. <label for="paypalexpress_order_review_password">Password:<span class="required">*</span></label> 
  225. <input type="password" name="password" id="paypalexpress_order_review_password" class="input-text" /> 
  226. </p> 
  227. <p class="form-row form-row-last"> 
  228. <label for="paypalexpress_order_review_repassword">Re Password:<span class="required">*</span></label> 
  229. <input type="password" name="repassword" id="paypalexpress_order_review_repassword" class="input-text"/> 
  230. </p> 
  231. <div class="clear"></div> 
  232. <p> 
  233. <input class="button" type="submit" name="createaccount" value="Create Account" /> 
  234. <input type="hidden" name="address" value="<?php echo WC()->customer->get_address(); ?>"> 
  235. </p> 
  236. </form> 
  237.  
  238. <?php do_action( 'angelleye_review_order_after_login_create_account' );?> 
  239.  
  240. <?php elseif (!$hide_button): 
  241. global $pp_settings; 
  242. $cancel_url = isset( $pp_settings['cancel_page'] ) ? get_permalink( $pp_settings['cancel_page'] ) : $woocommerce->cart->get_cart_url(); 
  243. $cancel_url = apply_filters( 'angelleye_review_order_cance_url', $cancel_url ); 
  244. echo '<div class="clear"></div>'; 
  245. $cancel_button = '<p><a class="button angelleye_cancel" href="' . $cancel_url . '">'.__('Cancel order', 'paypal-for-woocommerce').'</a> '; 
  246.  
  247. if ($is_paypal_express && wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) && empty( $checkout_form_data['terms'] ) ) { 
  248. ?> 
  249. <?php do_action( 'angelleye_review_order_before_place_order' ); 
  250.  
  251. $gateways = WC()->payment_gateways()->payment_gateways(); 
  252. if($gateways[ 'paypal_express' ]->supports( 'tokenization' )) : 
  253. echo sprintf( 
  254. '<p class="form-row woocommerce-SavedPaymentMethods-saveNew"> 
  255. <input id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" /> 
  256. <label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label> 
  257. </p>',  
  258. esc_attr( 'paypal_express' ),  
  259. esc_html__( 'Save PayPal Billing Agreement to Account', 'woocommerce' ) 
  260. );  
  261. endif; 
  262. ?> 
  263.  
  264. <script type="text/javascript"> 
  265. jQuery(document).ready(function () { 
  266. jQuery(".cls_place_order_own").click(function() { 
  267.  
  268. var ischecked = jQuery('.terms_own').is(':checked') ; 
  269.  
  270. if (ischecked == false) { 
  271. jQuery('.wp_notice_own').html('<div class="woocommerce-error"><?php echo __( 'You must accept our Terms & Conditions.', 'paypal-for-woocommerce' );?></div>'); 
  272.  
  273. // Scroll to .wp_notice_own to better highlight form *error*! 
  274. jQuery( "html, body" ).animate({ 
  275. scrollTop: ( jQuery( ".wp_notice_own" ).offset().top - 60 ) 
  276. }, 1000 );  
  277.  
  278. return false; 
  279. }else if (ischecked == true) { 
  280. jQuery('.wp_notice_own').html(''); 
  281. jQuery(this).attr('disabled', 'disabled').val('Processing'); 
  282.  
  283. jQuery(this).parents('form').submit(); 
  284. return true; 
  285.  
  286.  
  287.  
  288. }); 
  289.  
  290. }); 
  291. </script> 
  292. <style type="text/css"> 
  293. #payment{ 
  294. display:none; 
  295. .lbl_terms{ 
  296. float: left; 
  297. display: inline-block !important; 
  298. margin-right: 5px !important; 
  299. .terms_own 
  300. float: none; 
  301. margin-top: 8px !important; 
  302. display: inline-block !important; 
  303. </style> 
  304.  
  305. <p class="terms"> 
  306. <label for="terms" class="checkbox lbl_terms"> 
  307. <input type="checkbox" class="input-checkbox terms_own" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" /> 
  308. <?php printf( __( 'I’ve read and accept the <a href="%s" class="terms_chkbox" target="_blank">terms & conditions</a>', 'paypal-for-woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?> 
  309. </label>  
  310. <?php do_action( 'angelleye_review_order_after_terms' );?> 
  311. </p> 
  312. <?php echo $cancel_button;?> 
  313. <input type="button" class="button cls_place_order_own" value="<?php echo __( 'Place Order', 'paypal-for-woocommerce');?>" /></p> 
  314.  
  315. <?php do_action( 'angelleye_review_order_after_place_order' );?> 
  316.  
  317. <?php 
  318. } else { 
  319. $gateways = WC()->payment_gateways()->payment_gateways(); 
  320. if($gateways[ 'paypal_express' ]->supports( 'tokenization' )) : 
  321. echo sprintf( 
  322. '<p class="form-row woocommerce-SavedPaymentMethods-saveNew"> 
  323. <input id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" /> 
  324. <label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label> 
  325. </p>',  
  326. esc_attr( 'paypal_express' ),  
  327. esc_html__( 'Save PayPal Billing Agreement to Account', 'woocommerce' ) 
  328. );  
  329. endif; 
  330. do_action( 'angelleye_review_order_before_place_order' ); 
  331.  
  332. echo $cancel_button; 
  333. echo sprintf( '<input type="submit" class="button" onclick=" jQuery(this).attr(\'disabled\', \'disabled\').val(\'%1$s\'); jQuery(this).parents(\'form\').submit(); return false;" value="' . esc_attr__( 'Place Order', 'paypal-for-woocommerce' ) . '"/ ></p>' , esc_attr__( 'Processing', 'paypal-for-woocommerce' ) ); 
  334. do_action( 'angelleye_review_order_after_place_order' ); 
  335. ?> 
  336. </form><!--close the checkout form--> 
  337. <?php endif; ?> 
  338. <div class="clear"></div> 
  339.  
  340. <?php do_action( 'angelleye_review_order_after_checkout_form' );?> 
.