Merge branch 'WPprodigy-patch-2'
This commit is contained in:
commit
277dbeb029
|
@ -536,7 +536,7 @@ class WC_Checkout {
|
|||
WC()->cart->calculate_totals();
|
||||
|
||||
// Terms
|
||||
if ( ! isset( $_POST['woocommerce_checkout_update_totals'] ) && empty( $this->posted['terms'] ) && wc_get_page_id( 'terms' ) > 0 ) {
|
||||
if ( ! isset( $_POST['woocommerce_checkout_update_totals'] ) && empty( $this->posted['terms'] ) && wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) {
|
||||
wc_add_notice( __( 'You must accept our Terms & Conditions.', 'woocommerce' ), 'error' );
|
||||
}
|
||||
|
||||
|
|
|
@ -289,12 +289,22 @@ class WC_Form_Handler {
|
|||
WC()->customer->set_city( $order->billing_city );
|
||||
}
|
||||
|
||||
// Terms
|
||||
if ( ! empty( $_POST['terms-field'] ) && empty( $_POST['terms'] ) ) {
|
||||
wc_add_notice( __( 'You must accept our Terms & Conditions.', 'woocommerce' ), 'error' );
|
||||
return;
|
||||
}
|
||||
|
||||
// Update payment method
|
||||
if ( $order->needs_payment() ) {
|
||||
$payment_method = wc_clean( $_POST['payment_method'] );
|
||||
|
||||
$payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : false;
|
||||
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
if ( ! $payment_method ) {
|
||||
wc_add_notice( __( 'Invalid payment method.', 'woocommerce' ), 'error' );
|
||||
return;
|
||||
}
|
||||
|
||||
// Update meta
|
||||
update_post_meta( $order_id, '_payment_method', $payment_method );
|
||||
|
||||
|
@ -319,7 +329,6 @@ class WC_Form_Handler {
|
|||
wp_redirect( $result['redirect'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -328,7 +337,6 @@ class WC_Form_Handler {
|
|||
wp_safe_redirect( $order->get_checkout_order_received_url() );
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class WC_Shortcode_Checkout {
|
|||
// Pay for existing order
|
||||
$order_key = $_GET[ 'key' ];
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
|
||||
if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
|
||||
echo '<div class="woocommerce-error">' . __( 'Invalid order. If you have an account please log in and try again.', 'woocommerce' ) . ' <a href="' . wc_get_page_permalink( 'myaccount' ) . '" class="wc-forward">' . __( 'My Account', 'woocommerce' ) . '</a>' . '</div>';
|
||||
return;
|
||||
|
@ -95,14 +95,27 @@ class WC_Shortcode_Checkout {
|
|||
if ( $order->needs_payment() ) {
|
||||
|
||||
// Set customer location to order location
|
||||
if ( $order->billing_country )
|
||||
if ( $order->billing_country ) {
|
||||
WC()->customer->set_country( $order->billing_country );
|
||||
if ( $order->billing_state )
|
||||
}
|
||||
if ( $order->billing_state ) {
|
||||
WC()->customer->set_state( $order->billing_state );
|
||||
if ( $order->billing_postcode )
|
||||
}
|
||||
if ( $order->billing_postcode ) {
|
||||
WC()->customer->set_postcode( $order->billing_postcode );
|
||||
}
|
||||
|
||||
wc_get_template( 'checkout/form-pay.php', array( 'order' => $order ) );
|
||||
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
if ( sizeof( $available_gateways ) ) {
|
||||
current( $available_gateways )->set_current();
|
||||
}
|
||||
|
||||
wc_get_template( 'checkout/form-pay.php', array(
|
||||
'order' => $order,
|
||||
'available_gateways' => $available_gateways,
|
||||
'order_button_text' => apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'woocommerce' ) )
|
||||
) );
|
||||
|
||||
} else {
|
||||
wc_add_notice( sprintf( __( 'This order’s status is “%s”—it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
|
||||
|
@ -117,7 +130,7 @@ class WC_Shortcode_Checkout {
|
|||
// Pay for order after checkout step
|
||||
$order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : '';
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
|
||||
if ( $order->id == $order_id && $order->order_key == $order_key ) {
|
||||
|
||||
if ( $order->needs_payment() ) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.4.7
|
||||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
@ -31,77 +31,50 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( sizeof( $order->get_items() ) > 0 ) :
|
||||
foreach ( $order->get_items() as $item ) :
|
||||
echo '
|
||||
<tr>
|
||||
<td class="product-name">' . $item['name'].'</td>
|
||||
<td class="product-quantity">' . $item['qty'].'</td>
|
||||
<td class="product-subtotal">' . $order->get_formatted_line_subtotal( $item ) . '</td>
|
||||
</tr>';
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
<?php if ( sizeof( $order->get_items() ) > 0 ) : ?>
|
||||
<?php foreach ( $order->get_items() as $item ) : ?>
|
||||
<tr>
|
||||
<td class="product-name"><?php echo esc_html( $item['name'] ); ?></td>
|
||||
<td class="product-quantity"><?php echo esc_html( $item['qty'] ); ?></td>
|
||||
<td class="product-subtotal"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<?php
|
||||
if ( $totals = $order->get_order_item_totals() ) foreach ( $totals as $total ) :
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row" colspan="2"><?php echo $total['label']; ?></th>
|
||||
<td class="product-total"><?php echo $total['value']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
<?php if ( $totals = $order->get_order_item_totals() ) : ?>
|
||||
<?php foreach ( $totals as $total ) : ?>
|
||||
<tr>
|
||||
<th scope="row" colspan="2"><?php echo $total['label']; ?></th>
|
||||
<td class="product-total"><?php echo $total['value']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<div id="payment">
|
||||
<?php if ( $order->needs_payment() ) : ?>
|
||||
<ul class="payment_methods methods">
|
||||
<?php
|
||||
if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) {
|
||||
// Chosen Method
|
||||
if ( sizeof( $available_gateways ) ) {
|
||||
current( $available_gateways )->set_current();
|
||||
<ul class="payment_methods methods">
|
||||
<?php
|
||||
if ( ! empty( $available_gateways ) ) {
|
||||
foreach ( $available_gateways as $gateway ) {
|
||||
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
|
||||
}
|
||||
} else {
|
||||
echo '<li>' . apply_filters( 'woocommerce_no_available_payment_methods_message', __( 'Sorry, it seems that there are no available payment methods for your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) ) . '</li>';
|
||||
}
|
||||
|
||||
foreach ( $available_gateways as $gateway ) {
|
||||
?>
|
||||
<li class="payment_method_<?php echo $gateway->id; ?>">
|
||||
<input id="payment_method_<?php echo $gateway->id; ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> data-order_button_text="<?php echo esc_attr( $gateway->order_button_text ); ?>" />
|
||||
<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
|
||||
<?php
|
||||
if ( $gateway->has_fields() || $gateway->get_description() ) {
|
||||
echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display:none;">';
|
||||
$gateway->payment_fields();
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
|
||||
echo '<p>' . __( 'Sorry, it seems that there are no available payment methods for your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) . '</p>';
|
||||
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-row">
|
||||
<?php wp_nonce_field( 'woocommerce-pay' ); ?>
|
||||
<?php
|
||||
$pay_order_button_text = apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'woocommerce' ) );
|
||||
|
||||
echo apply_filters( 'woocommerce_pay_order_button_html', '<input type="submit" class="button alt" id="place_order" value="' . esc_attr( $pay_order_button_text ) . '" data-value="' . esc_attr( $pay_order_button_text ) . '" />' );
|
||||
?>
|
||||
<input type="hidden" name="woocommerce_pay" value="1" />
|
||||
|
||||
<?php echo apply_filters( 'woocommerce_pay_order_button_html', '<input type="submit" class="button alt" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />' ); ?>
|
||||
|
||||
<?php wc_get_template( 'checkout/terms.php' ); ?>
|
||||
|
||||
<?php wp_nonce_field( 'woocommerce-pay' ); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
|
|
@ -12,63 +12,48 @@
|
|||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.4.7
|
||||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! is_ajax() ) {
|
||||
do_action( 'woocommerce_review_order_before_payment' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( ! is_ajax() ) : ?>
|
||||
<?php do_action( 'woocommerce_review_order_before_payment' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="payment" class="woocommerce-checkout-payment">
|
||||
<?php if ( WC()->cart->needs_payment() ) : ?>
|
||||
<ul class="payment_methods methods">
|
||||
<?php
|
||||
if ( ! empty( $available_gateways ) ) {
|
||||
foreach ( $available_gateways as $gateway ) {
|
||||
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
|
||||
}
|
||||
} else {
|
||||
if ( ! WC()->customer->get_country() ) {
|
||||
$no_gateways_message = __( 'Please fill in your details above to see available payment methods.', 'woocommerce' );
|
||||
<ul class="payment_methods methods">
|
||||
<?php
|
||||
if ( ! empty( $available_gateways ) ) {
|
||||
foreach ( $available_gateways as $gateway ) {
|
||||
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
|
||||
}
|
||||
} else {
|
||||
$no_gateways_message = __( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' );
|
||||
echo '<li>' . apply_filters( 'woocommerce_no_available_payment_methods_message', WC()->customer->get_country() ? __( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) : __( 'Please fill in your details above to see available payment methods.', 'woocommerce' ) ) . '</li>';
|
||||
}
|
||||
|
||||
echo '<li>' . apply_filters( 'woocommerce_no_available_payment_methods_message', $no_gateways_message ) . '</li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-row place-order">
|
||||
|
||||
<noscript><?php _e( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ); ?><br/><input type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'woocommerce' ); ?>" /></noscript>
|
||||
|
||||
<?php wp_nonce_field( 'woocommerce-process_checkout' ); ?>
|
||||
<noscript>
|
||||
<?php _e( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ); ?>
|
||||
<br/><input type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'woocommerce' ); ?>" />
|
||||
</noscript>
|
||||
|
||||
<?php do_action( 'woocommerce_review_order_before_submit' ); ?>
|
||||
|
||||
<?php echo apply_filters( 'woocommerce_order_button_html', '<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />' ); ?>
|
||||
|
||||
<?php if ( wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) : ?>
|
||||
<p class="form-row terms">
|
||||
<label for="terms" class="checkbox"><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank">terms & conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></label>
|
||||
<input type="checkbox" class="input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" />
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_review_order_after_submit' ); ?>
|
||||
|
||||
<?php wc_get_template( 'checkout/terms.php' ); ?>
|
||||
|
||||
<?php wp_nonce_field( 'woocommerce-process_checkout' ); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( ! is_ajax() ) : ?>
|
||||
<?php do_action( 'woocommerce_review_order_after_payment' ); ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( ! is_ajax() ) {
|
||||
do_action( 'woocommerce_review_order_after_payment' );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Checkout terms and conditions checkbox
|
||||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.5.0
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) : ?>
|
||||
<p class="form-row terms">
|
||||
<label for="terms" class="checkbox"><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank">terms & conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></label>
|
||||
<input type="checkbox" class="input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" />
|
||||
<input type="hidden" name="terms-field" value="1" />
|
||||
</p>
|
||||
<?php endif; ?>
|
Loading…
Reference in New Issue