-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Kalpa-Services/1-payment-option-not-visibl…
…e-on-frontend 1 payment option not visible on frontend
- Loading branch information
Showing
5 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType; | ||
|
||
class WC_MMG_Payments_Blocks extends AbstractPaymentMethodType { | ||
protected $name = 'mmg_checkout'; | ||
|
||
public function initialize() { | ||
$this->settings = get_option('woocommerce_mmg_checkout_settings', array()); | ||
} | ||
|
||
public function is_active() { | ||
return ! empty($this->settings['enabled']) && 'yes' === $this->settings['enabled']; | ||
} | ||
|
||
public function get_payment_method_script_handles() { | ||
wp_register_script( | ||
'wc-mmg-payments-blocks', | ||
plugins_url('js/mmg-checkout-blocks.js', dirname(__FILE__)), | ||
array('wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), | ||
filemtime(plugin_dir_path(dirname(__FILE__)) . 'js/mmg-checkout-blocks.js'), | ||
true | ||
); | ||
return array('wc-mmg-payments-blocks'); | ||
} | ||
|
||
public function get_payment_method_data() { | ||
return array( | ||
'title' => $this->settings['title'], | ||
'description' => $this->settings['description'], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { registerPaymentMethod } = window.wc.wcBlocksRegistry; | ||
const { createElement } = window.wp.element; | ||
const { decodeEntities } = window.wp.htmlEntities; | ||
|
||
const MMGCheckoutLabel = ({ title }) => { | ||
return createElement('span', {}, decodeEntities(title)); | ||
}; | ||
|
||
const MMGCheckoutContent = ({ description }) => { | ||
return createElement('p', {}, decodeEntities(description)); | ||
}; | ||
|
||
registerPaymentMethod({ | ||
name: 'mmg_checkout', | ||
label: createElement(MMGCheckoutLabel, { title: mmgCheckoutData.title }), | ||
content: createElement(MMGCheckoutContent, { description: mmgCheckoutData.description }), | ||
edit: createElement(MMGCheckoutContent, { description: mmgCheckoutData.description }), | ||
canMakePayment: () => true, | ||
ariaLabel: decodeEntities(mmgCheckoutData.title), | ||
supports: { | ||
features: mmgCheckoutData.supports, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters