mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge pull request #203 from woocommerce/feature/PCP-184-extend-plugin-modification-options
Extend plugin modification options
This commit is contained in:
commit
4afa9d6096
3 changed files with 80 additions and 15 deletions
|
@ -182,7 +182,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
&& ! $this->session_handler->order()
|
&& ! $this->session_handler->order()
|
||||||
) {
|
) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_review_order_after_submit',
|
$this->checkout_dcc_button_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'dcc_renderer',
|
'dcc_renderer',
|
||||||
|
@ -191,7 +191,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
);
|
);
|
||||||
|
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_pay_order_after_submit',
|
$this->pay_order_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'dcc_renderer',
|
'dcc_renderer',
|
||||||
|
@ -255,7 +255,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
&& ! $not_enabled_on_cart
|
&& ! $not_enabled_on_cart
|
||||||
) {
|
) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_proceed_to_checkout',
|
$this->proceed_to_checkout_button_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'message_renderer',
|
'message_renderer',
|
||||||
|
@ -271,7 +271,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
&& ! $not_enabled_on_product_page
|
&& ! $not_enabled_on_product_page
|
||||||
) {
|
) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_single_product_summary',
|
$this->single_product_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'message_renderer',
|
'message_renderer',
|
||||||
|
@ -284,7 +284,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
! $this->settings->get( 'message_enabled' );
|
! $this->settings->get( 'message_enabled' );
|
||||||
if ( ! $not_enabled_on_checkout ) {
|
if ( ! $not_enabled_on_checkout ) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_review_order_after_submit',
|
$this->checkout_dcc_button_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'message_renderer',
|
'message_renderer',
|
||||||
|
@ -292,7 +292,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
11
|
11
|
||||||
);
|
);
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_pay_order_after_submit',
|
$this->pay_order_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'message_renderer',
|
'message_renderer',
|
||||||
|
@ -318,7 +318,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
&& ! $not_enabled_on_cart
|
&& ! $not_enabled_on_cart
|
||||||
) {
|
) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_proceed_to_checkout',
|
$this->proceed_to_checkout_button_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'button_renderer',
|
'button_renderer',
|
||||||
|
@ -334,7 +334,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
&& ! $not_enabled_on_product_page
|
&& ! $not_enabled_on_product_page
|
||||||
) {
|
) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_single_product_summary',
|
$this->single_product_renderer_hook(),
|
||||||
array(
|
array(
|
||||||
$this,
|
$this,
|
||||||
'button_renderer',
|
'button_renderer',
|
||||||
|
@ -349,7 +349,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
! $not_enabled_on_minicart
|
! $not_enabled_on_minicart
|
||||||
) {
|
) {
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_widget_shopping_cart_after_buttons',
|
$this->mini_cart_button_renderer_hook(),
|
||||||
static function () {
|
static function () {
|
||||||
echo '<p
|
echo '<p
|
||||||
id="ppc-button-minicart"
|
id="ppc-button-minicart"
|
||||||
|
@ -360,8 +360,8 @@ class SmartButton implements SmartButtonInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'woocommerce_review_order_after_payment', array( $this, 'button_renderer' ), 10 );
|
add_action( $this->checkout_button_renderer_hook(), array( $this, 'button_renderer' ), 10 );
|
||||||
add_action( 'woocommerce_pay_order_after_submit', array( $this, 'button_renderer' ), 10 );
|
add_action( $this->pay_order_renderer_hook(), array( $this, 'button_renderer' ), 10 );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -963,4 +963,64 @@ class SmartButton implements SmartButtonInterface {
|
||||||
|
|
||||||
return $height;
|
return $height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return action name PayPal buttons will be rendered at on checkout page.
|
||||||
|
*
|
||||||
|
* @return string Action name.
|
||||||
|
*/
|
||||||
|
private function checkout_button_renderer_hook(): string {
|
||||||
|
return (string) apply_filters( 'woocommerce_paypal_payments_checkout_button_renderer_hook', 'woocommerce_review_order_after_payment' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return action name PayPal DCC button will be rendered at on checkout page.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function checkout_dcc_button_renderer_hook(): string {
|
||||||
|
return (string) apply_filters( 'woocommerce_paypal_payments_checkout_dcc_renderer_hook', 'woocommerce_review_order_after_submit' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return action name PayPal button and Pay Later message will be rendered at on pay-order page.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function pay_order_renderer_hook(): string {
|
||||||
|
return (string) apply_filters( 'woocommerce_paypal_payments_pay_order_dcc_renderer_hook', 'woocommerce_pay_order_after_submit' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return action name PayPal button will be rendered next to Proceed to checkout button (normally displayed in cart).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function proceed_to_checkout_button_renderer_hook(): string {
|
||||||
|
return (string) apply_filters(
|
||||||
|
'woocommerce_paypal_payments_proceed_to_checkout_button_renderer_hook',
|
||||||
|
'woocommerce_proceed_to_checkout'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return action name PayPal button will be rendered in the WC mini cart.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function mini_cart_button_renderer_hook(): string {
|
||||||
|
return (string) apply_filters(
|
||||||
|
'woocommerce_paypal_payments_mini_cart_button_renderer_hook',
|
||||||
|
'woocommerce_widget_shopping_cart_after_buttons'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return action name PayPal button and Pay Later message will be rendered at on the single product page.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function single_product_renderer_hook(): string {
|
||||||
|
return (string) apply_filters( 'woocommerce_paypal_payments_single_product_renderer_hook', 'woocommerce_single_product_summary' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -761,7 +761,7 @@ return array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
'input_class' => array( 'wc-enhanced-select' ),
|
'input_class' => array( 'wc-enhanced-select' ),
|
||||||
'default' => 'paypal',
|
'default' => apply_filters( 'woocommerce_paypal_payments_button_label_default', 'paypal' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'This controls the label on the primary button.',
|
'This controls the label on the primary button.',
|
||||||
|
@ -1063,7 +1063,7 @@ return array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
'input_class' => array( 'wc-enhanced-select' ),
|
'input_class' => array( 'wc-enhanced-select' ),
|
||||||
'default' => 'paypal',
|
'default' => apply_filters( 'woocommerce_paypal_payments_button_product_label_default', 'paypal' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'This controls the label on the primary button.',
|
'This controls the label on the primary button.',
|
||||||
|
@ -1366,7 +1366,7 @@ return array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
'input_class' => array( 'wc-enhanced-select' ),
|
'input_class' => array( 'wc-enhanced-select' ),
|
||||||
'default' => 'paypal',
|
'default' => apply_filters( 'woocommerce_paypal_payments_button_cart_label_default', 'paypal' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'This controls the label on the primary button.',
|
'This controls the label on the primary button.',
|
||||||
|
@ -1669,7 +1669,7 @@ return array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'class' => array(),
|
'class' => array(),
|
||||||
'input_class' => array( 'wc-enhanced-select' ),
|
'input_class' => array( 'wc-enhanced-select' ),
|
||||||
'default' => 'paypal',
|
'default' => apply_filters( 'woocommerce_paypal_payments_button_mini_cart_label_default', 'paypal' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'This controls the label on the primary button.',
|
'This controls the label on the primary button.',
|
||||||
|
|
|
@ -77,6 +77,11 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
|
||||||
$modules[] = ( require $module_file )();
|
$modules[] = ( require $module_file )();
|
||||||
}
|
}
|
||||||
$providers = array();
|
$providers = array();
|
||||||
|
|
||||||
|
// Use this filter to add custom module or remove some of existing ones.
|
||||||
|
// Modules able to access container, add services and modify existing ones.
|
||||||
|
$modules = apply_filters( 'woocommerce_paypal_payments_modules', $modules );
|
||||||
|
|
||||||
foreach ( $modules as $module ) {
|
foreach ( $modules as $module ) {
|
||||||
/* @var $module ModuleInterface module */
|
/* @var $module ModuleInterface module */
|
||||||
$providers[] = $module->setup();
|
$providers[] = $module->setup();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue