woocommerce/plugins/woocommerce-admin/client/marketing/coupons/index.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
/**
* External dependencies
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
*/
import { __ } from '@wordpress/i18n';
import { useUser } from '@woocommerce/data';
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
/**
* Internal dependencies
*/
import './style.scss';
import RecommendedExtensions from './recommended-extensions';
import KnowledgeBase from './knowledge-base';
import { getAdminSetting } from '~/utils/admin-settings';
Add BFCM promo (#51739) * Populate `window.wcMarketplace` for Marketing > Coupons * TEST CODE: Add promotions dummy data to the endpoint for now See [this comment](https://github.com/Automattic/woocommerce.com/issues/21783#issuecomment-2376471712) as to how we plan to manage this through WCCOM * Initial implementation of the `<PromoCard>` component This commit does the following: - Implement the `PromoCard` component - Refactor the existing `Promotions` component - Extract types - Add support for conditional rendering based on `pathname` - Accept optional parameter `promoCardOnly` - Renders `PromoCard` wherever needed, as requested in the project thread. Some remaining TODOs: 1. Dismiss functionality 2. Tracking 3. Figma design adjustments - CSS styling (Flexbox in Marketplace, etc.) - Percent image, wherever needed - Background image 4. BWC testing (e.g. ensuring that "Get more for your money" banner still works) * Make sure that WCCOM also returns path so that earlier versions of in-app marketplace don't break (path undefined error) * Update T&C link After https://github.com/Automattic/woocommerce.com/issues/21840 * Implement promo banner dismissal logic and tracks * Styling the WooCommerce > Extensions version of the promo component. - Tweaked data on `class-wc-admin-assets.php` to pass `style` and `icon` attributes for that promo. - Moved promo on this page from the marketplace `Header` component to the `Content`, above the Sales Banner notices. - Deleted `percent.svg` and moved its content into a React component. - CSS tweaks for this style of promo. - Changes to elements of `PromoCard` component to allow the layout for this style. * Fixed some TypeScript issues. - Added guard condition in case `promotion.id` is undefined. - Returning null if it isn't - but below `useState` hook, so we conform to rules of hooks. - Setting default value for `promotion.cta_label` to satisfy TypeScript, which expects a node. Style tweaks to `.promo-cta`. Vertical centering of text, hover colour, margins. * Remove unnecessary unique identifier for each promo, and use a smarter way (URIs) to gather the visibility data * Lint * Revert test code * Changelog * Better code comments * Changed `promoCardOnly` attribute of `Promotions` to `format`, to allow for more types in future. * Update plugins/woocommerce-admin/client/marketplace/components/promotions/promotions.tsx Co-authored-by: Boro Sitnikovski <buritomath@gmail.com> * Styling promo cards at different breakpoints. Moved homescreen promo to after store management links. * Added condition to merge array of promos with the main `$promotions` array. * Added `useEffect` so we only record Track event for view of promotion once. Changed Tracks prefix to the shorter `marketplace_promo_`. * Added Tracks events for both formats of promotions, `promo-card`, and the original `notice`. * Merging two style blocks. * Passing `format` to `recordEvent` instead of hard-coding it. * Addressing linter errors. * Moved operation merging promos into the main array into a separate method for greater clarity. * Moved Promotions component on WooCommerce > Home to below task list. * Styling tweaks. Increased schedule of `woocommerce_marketplace_cron_fetch_promotions` cron job to twice daily. Added guard conditions in `Promotions` in case `window.wcMarketplace.promotions` isn't defined or isn't an array. * Reduced SVG size to 72px. * Fixing linter error. * Style tweaks. Using WP components colour vars for CTA and dismiss links. * Fixing linter error. * Reverting change to `schedule_cron_event`, as this method will not be present if only this branch is cherry-picked. --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2024-10-03 14:36:06 +00:00
import Promotions from '~/marketplace/components/promotions/promotions';
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
import '../data';
const CouponsOverview = () => {
const { currentUserCan } = useUser();
const showExtensions = !! (
getAdminSetting( 'allowMarketplaceSuggestions', false ) &&
currentUserCan( 'install_plugins' )
);
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
return (
<div className="woocommerce-marketing-coupons">
Add BFCM promo (#51739) * Populate `window.wcMarketplace` for Marketing > Coupons * TEST CODE: Add promotions dummy data to the endpoint for now See [this comment](https://github.com/Automattic/woocommerce.com/issues/21783#issuecomment-2376471712) as to how we plan to manage this through WCCOM * Initial implementation of the `<PromoCard>` component This commit does the following: - Implement the `PromoCard` component - Refactor the existing `Promotions` component - Extract types - Add support for conditional rendering based on `pathname` - Accept optional parameter `promoCardOnly` - Renders `PromoCard` wherever needed, as requested in the project thread. Some remaining TODOs: 1. Dismiss functionality 2. Tracking 3. Figma design adjustments - CSS styling (Flexbox in Marketplace, etc.) - Percent image, wherever needed - Background image 4. BWC testing (e.g. ensuring that "Get more for your money" banner still works) * Make sure that WCCOM also returns path so that earlier versions of in-app marketplace don't break (path undefined error) * Update T&C link After https://github.com/Automattic/woocommerce.com/issues/21840 * Implement promo banner dismissal logic and tracks * Styling the WooCommerce > Extensions version of the promo component. - Tweaked data on `class-wc-admin-assets.php` to pass `style` and `icon` attributes for that promo. - Moved promo on this page from the marketplace `Header` component to the `Content`, above the Sales Banner notices. - Deleted `percent.svg` and moved its content into a React component. - CSS tweaks for this style of promo. - Changes to elements of `PromoCard` component to allow the layout for this style. * Fixed some TypeScript issues. - Added guard condition in case `promotion.id` is undefined. - Returning null if it isn't - but below `useState` hook, so we conform to rules of hooks. - Setting default value for `promotion.cta_label` to satisfy TypeScript, which expects a node. Style tweaks to `.promo-cta`. Vertical centering of text, hover colour, margins. * Remove unnecessary unique identifier for each promo, and use a smarter way (URIs) to gather the visibility data * Lint * Revert test code * Changelog * Better code comments * Changed `promoCardOnly` attribute of `Promotions` to `format`, to allow for more types in future. * Update plugins/woocommerce-admin/client/marketplace/components/promotions/promotions.tsx Co-authored-by: Boro Sitnikovski <buritomath@gmail.com> * Styling promo cards at different breakpoints. Moved homescreen promo to after store management links. * Added condition to merge array of promos with the main `$promotions` array. * Added `useEffect` so we only record Track event for view of promotion once. Changed Tracks prefix to the shorter `marketplace_promo_`. * Added Tracks events for both formats of promotions, `promo-card`, and the original `notice`. * Merging two style blocks. * Passing `format` to `recordEvent` instead of hard-coding it. * Addressing linter errors. * Moved operation merging promos into the main array into a separate method for greater clarity. * Moved Promotions component on WooCommerce > Home to below task list. * Styling tweaks. Increased schedule of `woocommerce_marketplace_cron_fetch_promotions` cron job to twice daily. Added guard conditions in `Promotions` in case `window.wcMarketplace.promotions` isn't defined or isn't an array. * Reduced SVG size to 72px. * Fixing linter error. * Style tweaks. Using WP components colour vars for CTA and dismiss links. * Fixing linter error. * Reverting change to `schedule_cron_event`, as this method will not be present if only this branch is cherry-picked. --------- Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2024-10-03 14:36:06 +00:00
<Promotions format="promo-card" />
{ showExtensions && (
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
<RecommendedExtensions
title={ __(
'Recommended coupon extensions',
'woocommerce'
) }
description={ __(
'Take your coupon marketing to the next level with our recommended coupon extensions.',
'woocommerce'
) }
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
category="coupons"
/>
) }
<KnowledgeBase
category="coupons"
description={ __(
'Learn the ins and outs of successful coupon marketing from the experts at WooCommerce.',
'woocommerce'
) }
Add Coupon feature (https://github.com/woocommerce/woocommerce-admin/pull/4526) * Handle new object for posts and recommendations * Set breadcrumb parent for woocommerce-coupons to be woocommerce-marketing * Add main coupon wrapping component * Render coupon wrapper element below coupon table using wp-admin-scripts * Finish off implementing category param for data store resolvers * Create a helper trait for legacy coupons * Add coupon related titles and descriptions * Add note for the coupons being moved * Allow for querying by note name in the notes Data Store * Revamp coupon moved trait * Add the new note only if we don't have an unactioned note and perform a redirect to ensure menu updates * set_icon is deprecated * Move coupon menu, adding a note for customers * Translate title and descriptions * Whitespace * Account for coupon functionality being disabled * Hide legacy menu before redirect * Don’t keep adding the note if customer dismisses it from inbox * Move behind feature flag * Add note if feature enabled * Add filter to override coupon feature * Tweak option name to refer to wc_admin To help with finding etc. * use css variables * Add the new note only if we don't have an unactioned note * Switch the filter logic so `false` turns off the feature This is a bit more intuitive when utilizing the filter * Remove extraneous string and add trailing new lines * Use correct posts object in tests * Revert accidental removal of where_types * Add coupons category to RecommendedExtensions * Use 1.1 api to get categorized recommendations * Add missing text domains * Fix menu handling to point to woocommerce-marketing * Only load coupon scripts on the coupon page * Rework marketing menu logic to register pages more properly * Use correct wc-admin path for marketing page * Remove separate feature flag WC Admin has existing feature flags to load enable/disable the feature * Only set the coupon parent to marketing when the feature is enabled * Only load coupon feature if marketing feature is enabled Co-authored-by: Dan Bitzer <danielbitzer@gmail.com> Co-authored-by: Jeremy Pry <jeremy.pry@gmail.com>
2020-06-16 02:30:41 +00:00
/>
</div>
);
};
export default CouponsOverview;