Allow gateways to change the checkout place order button text on selection. Closes #4573
This commit is contained in:
parent
bd76784f97
commit
39344f2ed5
|
@ -163,6 +163,11 @@ jQuery(document).ready(function($) {
|
|||
} else {
|
||||
$('div.payment_box').show();
|
||||
}
|
||||
if ( $(this).data('order_button_text') ) {
|
||||
$('#place_order').val( $(this).data('order_button_text') );
|
||||
} else {
|
||||
$('#place_order').val( $('#place_order').data( 'value' ) );
|
||||
}
|
||||
})
|
||||
|
||||
// Trigger initial click
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -19,6 +19,9 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
/** @var string Payment method ID. */
|
||||
var $id;
|
||||
|
||||
/** @var string Set if the place order button should be renamed on selection. */
|
||||
var $order_button_text;
|
||||
|
||||
/** @var string Payment method title. */
|
||||
var $title;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
$this->id = 'paypal';
|
||||
$this->icon = apply_filters( 'woocommerce_paypal_icon', WC()->plugin_url() . '/assets/images/icons/paypal.png' );
|
||||
$this->has_fields = false;
|
||||
$this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' );
|
||||
$this->liveurl = 'https://www.paypal.com/cgi-bin/webscr';
|
||||
$this->testurl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
||||
$this->method_title = __( 'PayPal', 'woocommerce' );
|
||||
|
|
|
@ -189,6 +189,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Feature - New notices API for adding errors/notices
|
||||
* Feature - Compatible with WordPress 3.8 default theme 'TwentyFourteen'.
|
||||
* Feature - Added is_store_notice_showing conditional.
|
||||
* Feature - Allow gateways to change the checkout place order button text on selection.
|
||||
* Tweak - Added pagination to tax rate screens.
|
||||
* Tweak - Added filter to check the 'Create account' checkbox on checkout by default.
|
||||
* Tweak - Update CPT parameters for 'product_variation' and 'shop_coupon' to be no longer public.
|
||||
|
|
|
@ -62,7 +62,7 @@ global $woocommerce;
|
|||
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 if ( $gateway->chosen ) echo 'checked="checked"'; ?> />
|
||||
<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() ) {
|
||||
|
@ -87,7 +87,8 @@ global $woocommerce;
|
|||
<?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 ) . '" />' );
|
||||
|
||||
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" />
|
||||
</div>
|
||||
|
|
|
@ -132,7 +132,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
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 ); ?> />
|
||||
<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() ) :
|
||||
|
@ -167,7 +167,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<?php
|
||||
$order_button_text = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) );
|
||||
|
||||
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 ) . '" />' );
|
||||
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 ) ) {
|
||||
|
|
|
@ -23,7 +23,7 @@ global $woocommerce;
|
|||
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 if ($gateway->chosen) echo 'checked="checked"'; ?> />
|
||||
<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 ); ?> />
|
||||
<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() ) {
|
||||
|
|
Loading…
Reference in New Issue