mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +08:00
First attempt at fixing the PayLater Messaging block on the frontend. The block renders but with default config and not block specific settings.
This commit is contained in:
parent
6139f071e5
commit
d30b44d18e
6 changed files with 34 additions and 15 deletions
|
@ -420,6 +420,10 @@ class SmartButton implements SmartButtonInterface {
|
|||
return $this->messages_renderer_hook( $location, 'woocommerce_review_order_before_payment', 10 );
|
||||
case 'cart':
|
||||
return $this->messages_renderer_hook( $location, $this->proceed_to_checkout_button_renderer_hook(), 19 );
|
||||
case 'checkout-block':
|
||||
return $this->messages_renderer_hook( $location, 'ppcp-paylater-message-block', 10 );
|
||||
case 'cart-block':
|
||||
return $this->messages_renderer_hook( $location, 'ppcp-paylater-message-block', 10 );
|
||||
case 'pay-now':
|
||||
return $this->messages_renderer_hook( $location, $default_pay_order_hook, 10 );
|
||||
case 'product':
|
||||
|
@ -577,10 +581,6 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( in_array( $this->context(), array( 'checkout-block', 'cart-block' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->should_load_buttons() || $this->should_load_messages() || $this->can_render_dcc();
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,6 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
|
|||
$messaging_enabled_for_current_location = $this->settings_status->is_pay_later_messaging_enabled_for_location( $location );
|
||||
|
||||
$has_paylater_block = has_block( 'woocommerce-paypal-payments/paylater-messages' ) && PayLaterBlockModule::is_block_enabled( $this->settings_status );
|
||||
|
||||
switch ( $location ) {
|
||||
case 'checkout':
|
||||
case 'cart':
|
||||
|
@ -644,8 +643,9 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
|
|||
case 'block-editor':
|
||||
return true;
|
||||
case 'checkout-block':
|
||||
return $has_paylater_block;
|
||||
case 'cart-block':
|
||||
return $has_paylater_block || $this->is_block_editor();
|
||||
return $has_paylater_block;
|
||||
default:
|
||||
return $has_paylater_block;
|
||||
}
|
||||
|
@ -1856,8 +1856,7 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
|
|||
* @return bool true if is enabled, otherwise false.
|
||||
*/
|
||||
public function is_pay_later_messaging_enabled_for_location( string $location, array $context_data = array() ): bool {
|
||||
return $this->is_pay_later_filter_enabled_for_location( $location, $context_data )
|
||||
&& $this->settings_status->is_pay_later_messaging_enabled_for_location( $location );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,5 +48,6 @@
|
|||
},
|
||||
"textdomain": "woocommerce-paypal-payments",
|
||||
"editorScript": "ppcp-paylater-block",
|
||||
"editorStyle": "file:./assets/css/edit.css"
|
||||
"editorStyle": "file:./assets/css/edit.css",
|
||||
"render": "file:./src/PayLaterBlockRender.php"
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ const blockId = 'woocommerce-paypal-payments/paylater-messages';
|
|||
registerBlockType( blockId, {
|
||||
icon: paypalIcon,
|
||||
edit: Edit,
|
||||
save,
|
||||
save() {
|
||||
return null;
|
||||
},
|
||||
} );
|
||||
|
||||
document.addEventListener( 'DOMContentLoaded', () => {
|
||||
|
|
|
@ -22,5 +22,7 @@ export default function save( { attributes } ) {
|
|||
...paypalAttributes,
|
||||
};
|
||||
|
||||
return <div { ...useBlockProps.save(props) }></div>;
|
||||
return <div {...useBlockProps.save(props)}>
|
||||
<div id="ppcp-messages" data-partner-attribution-id="Woo_PPCP"></div>
|
||||
</div>;
|
||||
}
|
||||
|
|
17
modules/ppcp-paylater-block/src/PayLaterBlockRender.php
Normal file
17
modules/ppcp-paylater-block/src/PayLaterBlockRender.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* The Pay Later block render callback.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\PayLaterBlock
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\PayLaterBlock;
|
||||
|
||||
$attributes = get_block_wrapper_attributes()
|
||||
?>
|
||||
<div id="ppcp-paylater-message-block" <?php echo $attributes; ?>>
|
||||
<?php echo do_action('ppcp-paylater-message-block', $attributes); ?>
|
||||
</div>
|
||||
|
|
@ -36,7 +36,7 @@ class SettingsStatus {
|
|||
* Checks whether Pay Later messaging is enabled.
|
||||
*/
|
||||
public function is_pay_later_messaging_enabled(): bool {
|
||||
return $this->settings->has( 'pay_later_messaging_enabled' ) && $this->settings->get( 'pay_later_messaging_enabled' );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,9 +55,7 @@ class SettingsStatus {
|
|||
* @return bool true if is enabled, otherwise false.
|
||||
*/
|
||||
public function is_pay_later_messaging_enabled_for_location( string $location ): bool {
|
||||
return $this->is_pay_later_messaging_enabled() &&
|
||||
$this->has_pay_later_messaging_locations() &&
|
||||
$this->is_enabled_for_location( 'pay_later_messaging_locations', $location );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue