Skip to content

Commit

Permalink
Adds logic to dynamically display credits info in FAQ section on Land…
Browse files Browse the repository at this point in the history
…ing page.
  • Loading branch information
Kruti Dugade authored and Kruti Dugade committed Aug 21, 2023
1 parent 4c40c3c commit 5c47fa8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
36 changes: 25 additions & 11 deletions assets/source/setup-guide/app/views/LandingPageApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ const Feature = ( { title, text, imageUrl } ) => {
};

const FaqSection = () => {
const appSettings = useSettingsSelect();
const currencyCreditInfo = appSettings?.account_data?.currency_credit_info;

return (
<Card className="woocommerce-table pinterest-for-woocommerce-landing-page__faq-section">
<Panel
Expand Down Expand Up @@ -311,17 +314,28 @@ const FaqSection = () => {
'pinterest-for-woocommerce'
) }
/>
<FaqQuestion
questionId={ 'can-i-connect-to-multiple-accounts' }
question={ __(
'How do I redeem the $125 ad credit from Pinterest?',
'pinterest-for-woocommerce'
) }
answer={ __(
'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. Ad credits may vary by country and is subject to availability. Credits may take up to 24 hours to be credited to the user. Each user is only eligible to receive the ad credits once.',
'pinterest-for-woocommerce'
) }
/>
{ currencyCreditInfo && (
<FaqQuestion
questionId={ 'how-to-redeem-ad-credits' }
question={ sprintf(
// translators: %s: Amount of ad credits given with currency.
__(
'How do I redeem the %s ad credit from Pinterest?',
'pinterest-for-woocommerce'
),
currencyCreditInfo.creditsGiven
) }
answer={ 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 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. Ad credits may vary by country and is subject to availability. Credits may take up to 24 hours to be credited to the user. Each user is only eligible to receive the ad credits once.',
'pinterest-for-woocommerce'
),
currencyCreditInfo.creditsGiven,
currencyCreditInfo.spendRequire
) }
/>
) }
</Panel>
</Card>
);
Expand Down
3 changes: 3 additions & 0 deletions class-pinterest-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,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' ) );

Expand Down
1 change: 0 additions & 1 deletion src/API/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function __construct() {
*/
public function get_settings() {
Pinterest_For_Woocommerce()::maybe_check_billing_setup();
Pinterest_For_Woocommerce()::add_currency_credits_info_to_account_data();
return array(
PINTEREST_FOR_WOOCOMMERCE_OPTION_NAME => Pinterest_For_Woocommerce()::get_settings( true ),
);
Expand Down
4 changes: 2 additions & 2 deletions src/AdsCreditCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static function get_currency_credits() {
list( $spend_require, $credits_given ) = $credits_array;

$result = array(
'spendRequire' => html_entity_decode( wp_strip_all_tags( wc_price( $spend_require ) ) ),
'creditsGiven' => html_entity_decode( wp_strip_all_tags( wc_price( $credits_given ) ) ),
'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;
Expand Down

0 comments on commit 5c47fa8

Please sign in to comment.