Add ButtonInterface

Add render hooks to SmartButton
This commit is contained in:
Pedro Silva 2023-08-24 16:17:29 +01:00
parent f5163af958
commit e7e5ebde4e
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,40 @@
<?php
/**
* The interface for the button asset renderer.
*
* @package WooCommerce\PayPalCommerce\Button\Assets
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Button\Assets;
/**
* Interface SmartButtonInterface
*/
interface ButtonInterface {
/**
* Renders the necessary HTML.
*
* @return bool
*/
public function render_buttons(): bool;
/**
* Whether any of the scripts should be loaded.
*/
public function should_load_script(): bool;
/**
* Enqueues scripts/styles.
*/
public function enqueue(): void;
/**
* The configuration for the smart buttons.
*
* @return array
*/
public function script_data(): array;
}

View file

@ -463,6 +463,7 @@ class SmartButton implements SmartButtonInterface {
}
$this->button_renderer( PayPalGateway::ID );
do_action( 'woocommerce_paypal_payments_single_product_button_render' );
},
31
);
@ -483,6 +484,7 @@ class SmartButton implements SmartButtonInterface {
id="ppc-button-minicart"
class="woocommerce-mini-cart__buttons buttons"
></p>';
do_action( 'woocommerce_paypal_payments_minicart_button_render' );
},
30
);
@ -496,6 +498,7 @@ class SmartButton implements SmartButtonInterface {
function (): void {
$this->button_renderer( PayPalGateway::ID );
$this->button_renderer( CardButtonGateway::ID );
do_action( 'woocommerce_paypal_payments_payorder_button_render' );
},
20
);
@ -504,6 +507,7 @@ class SmartButton implements SmartButtonInterface {
function (): void {
$this->button_renderer( PayPalGateway::ID );
$this->button_renderer( CardButtonGateway::ID );
do_action( 'woocommerce_paypal_payments_checkout_button_render' );
}
);
@ -516,6 +520,7 @@ class SmartButton implements SmartButtonInterface {
}
$this->button_renderer( PayPalGateway::ID );
do_action( 'woocommerce_paypal_payments_cart_button_render' );
},
20
);