form-change-payment-method.php
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Pay for order form displayed after a customer has clicked the "Change Payment method" button
* next to a subscription on their My Account page.
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<form id="order_review" method="post">
<table class="shop_table">
<thead>
<tr>
<th class="product-name"><?php echo esc_html_x( 'Product', 'table headings in notification email', 'woocommerce-subscriptions' ); ?></th>
<th class="product-quantity"><?php echo esc_html_x( 'Quantity', 'table headings in notification email', 'woocommerce-subscriptions' ); ?></th>
<th class="product-total"><?php echo esc_html_x( 'Totals', 'table headings in notification email', 'woocommerce-subscriptions' ); ?></th>
</tr>
</thead>
<tfoot>
<?php
if ( $totals = $subscription->get_order_item_totals() ) {
foreach ( $totals as $total ) : ?>
<tr>
<th scope="row" colspan="2"><?php echo esc_html( $total['label'] ); ?></th>
<td class="product-total"><?php echo wp_kses_post( $total['value'] ); ?></td>
</tr>
<?php endforeach;
};
?>
</tfoot>
<tbody>
<?php
$recurring_order_items = $subscription->get_items();
if ( sizeof( $recurring_order_items ) > 0 ) :
foreach ( $recurring_order_items as $item ) :
echo '
<tr>
<td class="product-name">' . esc_html( $item['name'] ) . '</td>
<td class="product-quantity">' . esc_html( $item['qty'] ) . '</td>
<td class="product-subtotal">' . wp_kses_post( $subscription->get_formatted_line_subtotal( $item ) ) . '</td>
</tr>';
endforeach;
endif;
?>
</tbody>
</table>
<div id="payment">
<?php $pay_order_button_text = apply_filters( 'woocommerce_change_payment_button_text', _x( 'Change Payment Method', 'text on button on checkout page', 'woocommerce-subscriptions' ) );
if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) { ?>
<ul class="payment_methods methods">
<?php
if ( sizeof( $available_gateways ) ) {
current( $available_gateways )->set_current();
}
foreach ( $available_gateways as $gateway ) { ?>
<li>
<input id="payment_method_<?php echo esc_attr( $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( apply_filters( 'wcs_gateway_change_payment_button_text', $pay_order_button_text, $gateway ) ); ?>" />
<label for="payment_method_<?php echo esc_attr( $gateway->id ); ?>"><?php echo esc_html( $gateway->get_title() ); ?> <?php echo wp_kses_post( $gateway->get_icon() ); ?></label>
<?php
if ( $gateway->has_fields() || $gateway->get_description() ) {
echo '<div class="payment_box payment_method_' . esc_attr( $gateway->id ) . '" style="display:none;">';
$gateway->payment_fields();
echo '</div>';
}
?>
</li>
<?php
} ?>
</ul>
<?php } else { ?>
<div class="woocommerce-error">
<p> <?php esc_html_e( 'Sorry, it seems no payment gateways support changing the recurring payment method. Please contact us if you require assistance or to make alternate arrangements.', 'woocommerce-subscriptions' ); ?></p>
</div>
<?php } ?>
<?php if ( $available_gateways ) : ?>
<div class="form-row">
<?php wp_nonce_field( 'wcs_change_payment_method', '_wcsnonce', true, true ); ?>
<?php echo wp_kses( apply_filters( 'woocommerce_change_payment_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 ) . '" />' ), array( 'input' => array( 'type' => array(), 'class' => array(), 'id' => array(), 'value' => array(), 'data-value' => array() ) ) ); ?>
<input type="hidden" name="woocommerce_change_payment" value="<?php echo esc_attr( $subscription->id ); ?>" />
</div>
<?php endif; ?>
</div>
</form>