Skip to content

Commit

Permalink
Adding embedded card JS in WC block separately.
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung committed Aug 6, 2024
1 parent 23eecfb commit 3bc8d36
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion includes/blocks/assets/js/build/credit_card.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '5064f6bb58dd3352c00f30554738304a');
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '9d9c940edd665b09cdd8e15ab6212835');
2 changes: 1 addition & 1 deletion includes/blocks/assets/js/build/credit_card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions includes/blocks/gateways/omise-block-credit-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public function get_payment_method_script_handles() {
$script_asset = require_once __DIR__ . '/../assets/js/build/credit_card.asset.php';

if (is_array($script_asset)) {
wp_register_script(
'embedded-js',
plugins_url( '../../assets/javascripts/omise-embedded-card.js', __FILE__ ),
[],
OMISE_WOOCOMMERCE_PLUGIN_VERSION,
true
);

wp_register_script(
"{$this->name}-payments-blocks",
plugin_dir_url( __DIR__ ) . 'assets/js/build/credit_card.js',
Expand Down
16 changes: 0 additions & 16 deletions includes/class-omise-capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,6 @@ public static function shouldCallApi() {
return $isPaymentPage || $isOmiseSettingPage || $isFromCheckout;
}

/**
* Checks if checkout is the current page.
*
* @return boolean
*/
public static function better_is_checkout() {
$checkout_path = wp_parse_url(wc_get_checkout_url(), PHP_URL_PATH);
$current_url_path = wp_parse_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", PHP_URL_PATH);

return (
$checkout_path !== null
&& $current_url_path !== null
&& trailingslashit($checkout_path) === trailingslashit($current_url_path)
);
}

/**
* @param string|null $pKey
* @param string|null $sKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function get_payment_method_script_handles()
Monkey\Functions\expect('wp_script_is');
Monkey\Functions\expect('wp_register_script');
Monkey\Functions\expect('plugin_dir_url');
Monkey\Functions\expect('plugin_url');
Monkey\Functions\expect('is_checkout')->andReturn(true);
Monkey\Functions\expect('wc_string_to_bool')->andReturn(null);

Expand Down

0 comments on commit 3bc8d36

Please sign in to comment.