diff --git a/assets/source/catalog-sync/components/OnboardingModals/OnboardingAdsModal.js b/assets/source/catalog-sync/components/OnboardingModals/OnboardingAdsModal.js index 57b40ecf1..055520bd7 100644 --- a/assets/source/catalog-sync/components/OnboardingModals/OnboardingAdsModal.js +++ b/assets/source/catalog-sync/components/OnboardingModals/OnboardingAdsModal.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { createInterpolateElement } from '@wordpress/element'; import { Icon, external as externalIcon } from '@wordpress/icons'; import { @@ -18,13 +18,21 @@ import { useSettingsSelect } from '../../../setup-guide/app/helpers/effects'; import { useBillingSetupFlowEntered } from '../../helpers/effects'; const OnboardingModalText = ( { isBillingSetup } ) => { + const appSettings = useSettingsSelect(); + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; + if ( ! isBillingSetup ) { return ( { createInterpolateElement( - __( - 'You are eligible for $125 of Pinterest ad credits. To claim the credits, you would need to add your billing details and spend $15 on Pinterest ads.', - 'pinterest-for-woocommerce' + sprintf( + // translators: %1$s: Amount of ad credit given with currency. %2$s: Amount of money required to spend to claim ad credits with currency. + __( + 'You are eligible for %1$s of Pinterest ad credits. To claim the credits, you would need to add your billing details and spend %2$s on Pinterest ads.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven, + currencyCreditInfo.spendRequire ), { strong: , @@ -36,14 +44,22 @@ const OnboardingModalText = ( { isBillingSetup } ) => { return ( - { __( - 'You are eligible for $125 of Pinterest ad credits. To claim the credits, head over to the Pinterest ads manager and ', - 'pinterest-for-woocommerce' + { sprintf( + // translators: %s: Amount of ad credit given with currency. + __( + 'You are eligible for %s of Pinterest ad credits. To claim the credits, head over to the Pinterest ads manager and ', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven ) } - { __( - 'spend $15 on Pinterest ads.', - 'pinterest-for-woocommerce' + { sprintf( + // translators: %s: Amount of money required to spend to claim ad credits with currency. + __( + 'spend %s on Pinterest ads.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.spendRequire ) } @@ -61,6 +77,7 @@ const OnboardingModalText = ( { isBillingSetup } ) => { const OnboardingAdsModal = ( { onCloseModal } ) => { const appSettings = useSettingsSelect(); const isBillingSetup = appSettings?.account_data?.is_billing_setup; + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; const billingSetupFlowEntered = useBillingSetupFlowEntered(); const onClickBilling = () => { @@ -83,9 +100,13 @@ const OnboardingAdsModal = ( { onCloseModal } ) => { className="pinterest-for-woocommerce-catalog-sync__onboarding-modal" > - { __( - 'You are one step away from claiming $125 of Pinterest ad credits.', - 'pinterest-for-woocommerce' + { sprintf( + // translators: %s: Amount of ad credit given with currency. + __( + 'You are one step away from claiming %s of Pinterest ad credits.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven ) } diff --git a/assets/source/catalog-sync/sections/AdCreditsNotice.js b/assets/source/catalog-sync/sections/AdCreditsNotice.js index 939f05e61..2aadbc3e2 100644 --- a/assets/source/catalog-sync/sections/AdCreditsNotice.js +++ b/assets/source/catalog-sync/sections/AdCreditsNotice.js @@ -2,7 +2,7 @@ * External dependencies */ import { recordEvent } from '@woocommerce/tracks'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { createInterpolateElement, useCallback, @@ -49,6 +49,7 @@ const AdCreditsNotice = () => { const appSettings = useSettingsSelect(); const isBillingSetup = appSettings?.account_data?.is_billing_setup; const trackingAdvertiser = appSettings?.tracking_advertiser; + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; const closeAdCreditsNotice = () => { setIsNoticeDisplayed( false ); @@ -79,16 +80,27 @@ const AdCreditsNotice = () => { /> { isBillingSetup ? ( - { __( - 'Spend $15 to claim $125 Pinterest ad credits. (Ad credits may take up to 24 hours to be credited to account).' + { sprintf( + // translators: %1$s: Amount of money required to spend to claim ad credits with currency. %2$s: Amount of ad credits given with currency. + __( + 'Spend %1$s to claim %2$s in Pinterest ad credits. (Ad credits may take up to 24 hours to be credited to account).', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.spendRequire, + currencyCreditInfo.creditsGiven ) } ) : ( { createInterpolateElement( - __( - 'Spend $15 to get $125 in Pinterest ad credits. To claim the credits, add your billing details.', - 'pinterest-for-woocommerce' + sprintf( + // translators: %1$s: Amount of money required to spend to claim ad credits with currency. %2$s: Amount of ad credits given with currency. + __( + 'Spend %1$s to claim %2$s in Pinterest ad credits. To claim the credits, add your billing details.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.spendRequire, + currencyCreditInfo.creditsGiven ), { adsBillingDetails: trackingAdvertiser ? ( diff --git a/assets/source/setup-guide/app/components/TermsAndConditionsModal.js b/assets/source/setup-guide/app/components/TermsAndConditionsModal.js index d2c8646ac..789c1e4eb 100644 --- a/assets/source/setup-guide/app/components/TermsAndConditionsModal.js +++ b/assets/source/setup-guide/app/components/TermsAndConditionsModal.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { createInterpolateElement } from '@wordpress/element'; import { Modal, @@ -11,6 +11,7 @@ import { /** * Internal dependencies */ +import { useSettingsSelect } from '../helpers/effects'; import documentationLinkProps from '../helpers/documentation-link-props'; const tosHref = 'https://business.pinterest.com/business-terms-of-service/'; @@ -30,6 +31,9 @@ const advertisingServicesAgreementHref = * @return {JSX.Element} Rendered element. */ const AdsCreditsTermsAndConditionsModal = ( { onModalClose } ) => { + const appSettings = useSettingsSelect(); + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; + return ( { className="pinterest-for-woocommerce-landing-page__credits-section__tac-modal" > - { __( - 'To be eligible and redeem the $125 ad credit from Pinterest, you must complete the setup of Pinterest for WooCommerce, set up your billing with Pinterest Ads manager, and spend $15 with Pinterest ads. Credits may take up to 24 hours to be credited to the user.', - 'pinterest-for-woocommerce' + { sprintf( + // translators: %1$s: Amount of ad credit given with currency. %2$s: Amount of money required to spend to claim ad credits with currency. + __( + 'To be eligible and redeem the %1$s ad credit from Pinterest, you must complete the setup of Pinterest for WooCommerce, set up your billing with Pinterest Ads manager, and spend %2$s with Pinterest ads. Credits may take up to 24 hours to be credited to the user.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven, + currencyCreditInfo.spendRequire ) } diff --git a/assets/source/setup-guide/app/steps/components/AdsCreditsPromo.js b/assets/source/setup-guide/app/steps/components/AdsCreditsPromo.js index 532976982..bdf876ac1 100644 --- a/assets/source/setup-guide/app/steps/components/AdsCreditsPromo.js +++ b/assets/source/setup-guide/app/steps/components/AdsCreditsPromo.js @@ -2,7 +2,7 @@ * External dependencies */ import { useState, createInterpolateElement } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { recordEvent } from '@woocommerce/tracks'; import { CardDivider, @@ -42,6 +42,8 @@ const AdsCreditsPromo = () => { } ); }; + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; + return appSettings?.ads_campaign_is_active ? ( <> { { createInterpolateElement( - __( - 'As a new Pinterest customer, you can get $125 in free ad credits when you successfully set up Pinterest for WooCommerce and spend $15 on Pinterest Ads. Pinterest Terms and conditions apply.', - 'pinterest-for-woocommerce' + sprintf( + // translators: %1$s: Amount of ad credits given with currency. %2$s: Amount of money required to spend to claim ad credits with currency. + __( + 'As a new Pinterest customer, you can get %1$s in free ad credits when you successfully set up Pinterest for WooCommerce and spend %2$s on Pinterest Ads. Pinterest Terms and conditions apply.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven, + currencyCreditInfo.spendRequire ), { a: ( diff --git a/assets/source/setup-guide/app/views/LandingPageApp.js b/assets/source/setup-guide/app/views/LandingPageApp.js index 848fe5cab..b28b4e193 100644 --- a/assets/source/setup-guide/app/views/LandingPageApp.js +++ b/assets/source/setup-guide/app/views/LandingPageApp.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { getNewPath, getHistory } from '@woocommerce/navigation'; import { createInterpolateElement, @@ -159,6 +159,9 @@ const AdsCreditSection = () => { } ); }; + const appSettings = useSettingsSelect(); + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; + return ( @@ -173,16 +176,25 @@ const AdsCreditSection = () => { - { __( - 'Try Pinterest for WooCommerce and get $125 in ad credits!', - 'pinterest-for-woocommerce' + { sprintf( + // translators: %s: Amount of ad credits given with currency. + __( + 'Try Pinterest for WooCommerce and get %s in ad credits!', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven ) } { createInterpolateElement( - __( - 'To help you get started with Pinterest Ads, new Pinterest customers can get $125 in ad credits when they have successfully set up Pinterest for WooCommerce and spend $15 on Pinterest Ads. Pinterest Terms and conditions apply.', - 'pinterest-for-woocommerce' + sprintf( + // translators: %1$s: Amount of ad credits given with currency. %2$s: Amount of money required to spend to claim ad credits with currency. + __( + 'To help you get started with Pinterest Ads, new Pinterest customers can get %1$s in ad credits when they have successfully set up Pinterest for WooCommerce and spend %2$s on Pinterest Ads. Pinterest Terms and conditions apply.', + 'pinterest-for-woocommerce' + ), + currencyCreditInfo.creditsGiven, + currencyCreditInfo.spendRequire ), { a: ( @@ -269,6 +281,9 @@ const Feature = ( { title, text, imageUrl } ) => { }; const FaqSection = () => { + const appSettings = useSettingsSelect(); + const currencyCreditInfo = appSettings?.account_data?.currency_credit_info; + return ( { 'pinterest-for-woocommerce' ) } /> - + { currencyCreditInfo && ( + + ) } ); diff --git a/changelog.txt b/changelog.txt index 9f13fb33a..0919e98af 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,10 @@ *** Pinterest for WooCommerce Changelog *** += 1.3.9 - 2023-09-05 = +* Add - Adds logic to dynamically display spend requirement and credits given based on store currency. +* Fix - Uninstall procedure. +* Tweak - WC 8.1 compatibility. + = 1.3.8 - 2023-08-15 = * Fix - Caching of API calls. * Fix - Make add to cart events independent from WooCommerce archive page settings. diff --git a/class-pinterest-for-woocommerce.php b/class-pinterest-for-woocommerce.php index ce990f0ff..b76ca107f 100644 --- a/class-pinterest-for-woocommerce.php +++ b/class-pinterest-for-woocommerce.php @@ -9,6 +9,7 @@ use Automattic\WooCommerce\Pinterest as Pinterest; use Automattic\WooCommerce\Pinterest\AdCredits; use Automattic\WooCommerce\Pinterest\AdCreditsCoupons; +use Automattic\WooCommerce\Pinterest\AdsCreditCurrency; use Automattic\WooCommerce\Pinterest\Billing; use Automattic\WooCommerce\Pinterest\Heartbeat; use Automattic\WooCommerce\Pinterest\Notes\MarketingNotifications; @@ -279,6 +280,9 @@ public function init_plugin() { // Verify that the ads_campaign is active or not. add_action( 'admin_init', array( Pinterest\AdCredits::class, 'check_if_ads_campaign_is_active' ) ); + // Append credits info to account data. + add_action( 'init', array( $this, 'add_currency_credits_info_to_account_data' ) ); + add_action( 'pinterest_for_woocommerce_token_saved', array( $this, 'set_default_settings' ) ); add_action( 'pinterest_for_woocommerce_token_saved', array( $this, 'update_account_data' ) ); @@ -1020,6 +1024,20 @@ public static function add_redeem_credits_info_to_account_data() { self::save_setting( 'account_data', $account_data ); } + /** + * Add currency_credit_info information to the account data option. + * + * @since 1.3.9 + * + * @return void + */ + public static function add_currency_credits_info_to_account_data() { + $account_data = self::get_setting( 'account_data' ); + $currency_credit_info = AdsCreditCurrency::get_currency_credits(); + $account_data['currency_credit_info'] = $currency_credit_info; + self::save_setting( 'account_data', $account_data ); + } + /** * Add available credits information to the account data option. * diff --git a/package-lock.json b/package-lock.json index 29028fd4d..9ab38cdf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pinterest-for-woocommerce", - "version": "1.3.8", + "version": "1.3.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 51079799d..c2fe8747c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pinterest-for-woocommerce", "title": "Pinterest for WooCommerce", "description": "Pinterest for WooCommerce", - "version": "1.3.8", + "version": "1.3.9", "main": "gulpfile.js", "repository": { "type": "git", diff --git a/pinterest-for-woocommerce.php b/pinterest-for-woocommerce.php index bdcc134a0..443c5074b 100644 --- a/pinterest-for-woocommerce.php +++ b/pinterest-for-woocommerce.php @@ -13,7 +13,7 @@ * Plugin Name: Pinterest for WooCommerce * Plugin URI: https://woocommerce.com/products/pinterest-for-woocommerce/ * Description: Grow your business on Pinterest! Use this official plugin to allow shoppers to Pin products while browsing your store, track conversions, and advertise on Pinterest. - * Version: 1.3.8 + * Version: 1.3.9 * Author: WooCommerce * Author URI: https://woocommerce.com * License: GPL-2.0+ @@ -26,7 +26,7 @@ * Requires PHP: 7.3 * * WC requires at least: 5.3 - * WC tested up to: 8.0 + * WC tested up to: 8.1 */ /** @@ -46,7 +46,7 @@ } define( 'PINTEREST_FOR_WOOCOMMERCE_PLUGIN_FILE', __FILE__ ); -define( 'PINTEREST_FOR_WOOCOMMERCE_VERSION', '1.3.8' ); // WRCS: DEFINED_VERSION. +define( 'PINTEREST_FOR_WOOCOMMERCE_VERSION', '1.3.9' ); // WRCS: DEFINED_VERSION. // HPOS compatibility declaration. add_action( diff --git a/readme.txt b/readme.txt index 89e358be9..38a662c4b 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: woocommerce, pinterest, advertise Requires at least: 5.6 Tested up to: 6.3 Requires PHP: 7.3 -Stable tag: 1.3.8 +Stable tag: 1.3.9 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -91,6 +91,11 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](hhttps: == Changelog == += 1.3.9 - 2023-09-05 = +* Add - Adds logic to dynamically display spend requirement and credits given based on store currency. +* Fix - Uninstall procedure. +* Tweak - WC 8.1 compatibility. + = 1.3.8 - 2023-08-15 = * Fix - Caching of API calls. * Fix - Make add to cart events independent from WooCommerce archive page settings. diff --git a/src/AdsCreditCurrency.php b/src/AdsCreditCurrency.php new file mode 100644 index 000000000..21e5e83e7 --- /dev/null +++ b/src/AdsCreditCurrency.php @@ -0,0 +1,64 @@ + array( 15, 125 ), + 'EUR' => array( 15, 131 ), + 'GBP' => array( 13, 117 ), + 'BRL' => array( 80, 673 ), + 'CAD' => array( 20, 172 ), + 'AUD' => array( 23, 195 ), + 'MXN' => array( 305, 2548 ), + 'ARS' => array( 2198, 18320 ), + 'CHF' => array( 14, 124 ), + 'CZK' => array( 385, 3216 ), + 'DKK' => array( 116, 970 ), + 'HUF' => array( 6366, 53050 ), + 'JPY' => array( 2172, 18102 ), + 'NOK' => array( 162, 1353 ), + 'NZD' => array( 26, 222 ), + 'PLN' => array( 74, 624 ), + 'RON' => array( 77, 646 ), + 'SEK' => array( 170, 1424 ), + ); + + /** + * Get spend requirement and credits based on currency. + * + * @since 1.3.9 + * + * @return array $result Amount to be spent, credits given and currency symbol. + */ + public static function get_currency_credits() { + + $currency = get_woocommerce_currency(); + $credits_array = ( ! array_key_exists( $currency, self::$currency_credits_map ) || 'USD' === $currency ) ? self::$currency_credits_map['USD'] : self::$currency_credits_map[ $currency ]; + list( $spend_require, $credits_given ) = $credits_array; + + $result = array( + 'spendRequire' => html_entity_decode( wp_strip_all_tags( wc_price( $spend_require, array( 'decimals' => 0 ) ) ) ), + 'creditsGiven' => html_entity_decode( wp_strip_all_tags( wc_price( $credits_given, array( 'decimals' => 0 ) ) ) ), + ); + + return $result; + } +} diff --git a/uninstall.php b/uninstall.php index 5990c48e5..ae118903d 100644 --- a/uninstall.php +++ b/uninstall.php @@ -14,15 +14,22 @@ exit; } -/** - * Remove the feed configuration. - */ -$data = get_option( 'pinterest_for_woocommerce_data', [] ); -$merchant_id = $data['merchant_id'] ?? ''; +try { + // Load classes. + require_once __DIR__ . '/pinterest-for-woocommerce.php'; + + /** + * Remove the feed configuration. + */ + $data = get_option( 'pinterest_for_woocommerce_data', [] ); + $merchant_id = $data['merchant_id'] ?? ''; -if ( $merchant_id ) { - // At this time all feeds are considered stale so we just need pass bogus value as the second argument. - FeedRegistration::maybe_disable_stale_feeds_for_merchant( $merchant_id, '' ); + if ( $merchant_id ) { + // At this time all feeds are considered stale so we just need pass bogus value as the second argument. + FeedRegistration::maybe_disable_stale_feeds_for_merchant( $merchant_id, '' ); + } +} catch ( Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch + // Do nothing - this is a cleanup routine. } $plugin_settings = get_option( 'pinterest_for_woocommerce' );