SettingsOnboardCta.php
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* WooCommerce Payments Multi-Currency Settings
*
* @package WooCommerce\Admin
*/
namespace WCPay\MultiCurrency;
defined( 'ABSPATH' ) || exit;
/**
* MultiCurrency settings placeholder containing a CTA to connect the account.
*/
class SettingsOnboardCta extends \WC_Settings_Page {
/**
* Link to the Multi-Currency documentation page.
*
* @var string
*/
const LEARN_MORE_URL = 'https://woocommerce.com/document/payments/currencies/multi-currency-setup/';
/**
* MultiCurrency instance.
*
* @var MultiCurrency
*/
private $multi_currency;
/**
* Constructor.
*
* @param MultiCurrency $multi_currency The MultiCurrency instance.
*/
public function __construct( MultiCurrency $multi_currency ) {
$this->multi_currency = $multi_currency;
$this->id = $this->multi_currency->id;
$this->label = _x( 'Multi-currency', 'Settings tab label', 'woocommerce-payments' );
add_action( 'woocommerce_admin_field_wcpay_currencies_settings_onboarding_cta', [ $this, 'currencies_settings_onboarding_cta' ] );
parent::__construct();
}
/**
* Output the call to action button if needing to onboard.
*/
public function currencies_settings_onboarding_cta() {
$params = [
'page' => 'wc-admin',
'path' => '/payments/connect',
];
$href = admin_url( add_query_arg( $params, 'admin.php' ) );
?>
<div>
<p>
<?php esc_html_e( 'To add new currencies to your store, please finish setting up WooCommerce Payments.', 'woocommerce-payments' ); ?>
</p>
<a href="<?php echo esc_url( $href ); ?>" id="wcpay_enabled_currencies_onboarding_cta" type="button" class="button-primary">
<?php esc_html_e( 'Get started', 'woocommerce-payments' ); ?>
</a>
</div>
<?php
}
/**
* Get settings array.
*
* @param string $current_section Section being shown.
* @return array
*/
public function get_settings( $current_section = '' ) {
return [
[
'title' => __( 'Enabled currencies', 'woocommerce-payments' ),
'desc' => sprintf(
/* translators: %s: url to documentation. */
__( 'Accept payments in multiple currencies. Prices are converted based on exchange rates and rounding rules. <a href="%s">Learn more</a>', 'woocommerce-payments' ),
self::LEARN_MORE_URL
),
'type' => 'title',
'id' => $this->id . '_enabled_currencies',
],
[
'type' => 'wcpay_currencies_settings_onboarding_cta',
],
];
}
}