mirror of
https://github.com/10h30/woo-viet.git
synced 2026-07-11 18:56:13 +09:00
Add settings to handle OnePay Intl gateway
This commit is contained in:
@@ -115,7 +115,33 @@ class WooViet_Admin_Page {
|
|||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><?php _e( 'Add the OnePay International Gateway', 'woo-viet' ) ?></th>
|
||||||
|
<td>
|
||||||
|
<input name="settings[add_onepay_international][enabled]" type="hidden" value="no">
|
||||||
|
<input name="settings[add_onepay_international][enabled]" type="checkbox"
|
||||||
|
id="add_onepay_international" value="yes"
|
||||||
|
<?php if ( 'yes' == $settings['add_onepay_international']['enabled'] )
|
||||||
|
echo 'checked="checked"' ?>>
|
||||||
|
<label for="add_onepay_international"><?php _e( 'Enabled', 'woo-viet' ) ?></label>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<label for="">
|
||||||
|
<?php
|
||||||
|
echo sprintf( __( 'Your store currency is <code>%s</code>. ', 'woo-viet' ), get_woocommerce_currency() );
|
||||||
|
// Handle whether or not the store current is VND
|
||||||
|
if ( 'VND' == get_woocommerce_currency() ) {
|
||||||
|
_e( 'OnePay can work on your site.', 'woo-viet' );
|
||||||
|
echo '<br/>';
|
||||||
|
echo sprintf( __( 'Please configure this gateway under <a href="%s">WooCommerce -> Settings -> Checkout</a>.', 'woo-viet' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=wooviet_onepay_international' ) );
|
||||||
|
} else {
|
||||||
|
_e( '<span style="color: red" ">This gateway is not active on your site. Because OnePay supports VND only.</span>', 'woo-viet' );
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php _e( 'Add provinces for Vietnam', 'woo-viet' ) ?></th>
|
<th scope="row"><?php _e( 'Add provinces for Vietnam', 'woo-viet' ) ?></th>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
+35
-15
@@ -68,6 +68,10 @@ class WooViet {
|
|||||||
array(
|
array(
|
||||||
'enabled' => 'yes',
|
'enabled' => 'yes',
|
||||||
),
|
),
|
||||||
|
'add_onepay_international' =>
|
||||||
|
array(
|
||||||
|
'enabled' => 'yes',
|
||||||
|
),
|
||||||
'vnd_paypal_express_checkout' =>
|
'vnd_paypal_express_checkout' =>
|
||||||
array(
|
array(
|
||||||
'enabled' => 'yes',
|
'enabled' => 'yes',
|
||||||
@@ -161,7 +165,10 @@ class WooViet {
|
|||||||
) {
|
) {
|
||||||
include( 'inc/class-wooviet-onepay-domestic.php' );
|
include( 'inc/class-wooviet-onepay-domestic.php' );
|
||||||
|
|
||||||
add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateway_class' ) );
|
add_filter( 'woocommerce_payment_gateways', function ( $methods ) {
|
||||||
|
$methods[] = 'WooViet_OnePay_Domestic';
|
||||||
|
return $methods;
|
||||||
|
} );
|
||||||
|
|
||||||
// Add the action to check the cron job for handling queryDR
|
// Add the action to check the cron job for handling queryDR
|
||||||
// It's not possible to add in the class "WooViet_OnePay_Domestic_Hook" because it's NOT always loadded
|
// It's not possible to add in the class "WooViet_OnePay_Domestic_Hook" because it's NOT always loadded
|
||||||
@@ -175,6 +182,33 @@ class WooViet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if "Add the OnePay International Gateway" is enabled
|
||||||
|
* @since 1.5.0
|
||||||
|
*/
|
||||||
|
if ( 'yes' == $settings['add_onepay_international']['enabled']
|
||||||
|
AND 'VND' == get_woocommerce_currency()
|
||||||
|
) {
|
||||||
|
include( 'inc/class-wooviet-onepay-international.php' );
|
||||||
|
|
||||||
|
add_filter( 'woocommerce_payment_gateways', function ( $methods ) {
|
||||||
|
$methods[] = 'WooViet_OnePay_International';
|
||||||
|
return $methods;
|
||||||
|
} );
|
||||||
|
|
||||||
|
/// TODO check this code - it may not work properly and duplicate of Domestic
|
||||||
|
// Add the action to check the cron job for handling queryDR
|
||||||
|
// It's not possible to add in the class "WooViet_OnePay_Domestic_Hook" because it's NOT always loadded
|
||||||
|
if ( defined( 'DOING_CRON' ) and DOING_CRON ) {
|
||||||
|
$this->WooViet_OnePay_International_Hook = new WooViet_OnePay_International();
|
||||||
|
add_action( 'wooviet_handle_onepay_querydr', array(
|
||||||
|
$this->WooViet_OnePay_International_Hook,
|
||||||
|
'handle_onepay_querydr'
|
||||||
|
), 10, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Check if "Add provinces for Vietnam " is enabled.
|
// Check if "Add provinces for Vietnam " is enabled.
|
||||||
if ( 'yes' == $settings['add_province']['enabled'] ) {
|
if ( 'yes' == $settings['add_province']['enabled'] ) {
|
||||||
include( WOO_VIET_DIR . 'inc/class-wooviet-provinces.php' );
|
include( WOO_VIET_DIR . 'inc/class-wooviet-provinces.php' );
|
||||||
@@ -234,20 +268,6 @@ class WooViet {
|
|||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the gateways to WooCommerce
|
|
||||||
*
|
|
||||||
* @param array $methods
|
|
||||||
*
|
|
||||||
* @since 1.3
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function add_gateway_class( $methods ) {
|
|
||||||
$methods[] = 'WooViet_OnePay_Domestic';
|
|
||||||
|
|
||||||
return $methods;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add "Settings" link in the Plugins list page when the plugin is active
|
* Add "Settings" link in the Plugins list page when the plugin is active
|
||||||
|
|||||||
Reference in New Issue
Block a user