at path:
ROOT
/
wp-content
/
plugins
/
woocommerce
/
src
/
Internal
/
Admin
/
Coupons.php
run:
R
W
Run
Agentic
DIR
2026-04-15 05:42:46
R
W
Run
BlockTemplates
DIR
2026-04-15 05:42:46
R
W
Run
EmailImprovements
DIR
2026-04-15 05:42:46
R
W
Run
EmailPreview
DIR
2026-04-15 05:42:46
R
W
Run
Emails
DIR
2026-04-15 05:42:46
R
W
Run
ImportExport
DIR
2026-04-15 05:42:46
R
W
Run
Logging
DIR
2026-04-15 05:42:46
R
W
Run
Marketing
DIR
2026-04-15 05:42:46
R
W
Run
Notes
DIR
2026-04-15 05:42:46
R
W
Run
Onboarding
DIR
2026-04-15 05:42:46
R
W
Run
Orders
DIR
2026-04-15 05:42:46
R
W
Run
ProductForm
DIR
2026-04-15 05:42:46
R
W
Run
ProductReviews
DIR
2026-04-15 05:42:46
R
W
Run
RemoteFreeExtensions
DIR
2026-04-15 05:42:46
R
W
Run
Schedulers
DIR
2026-04-15 05:42:46
R
W
Run
Settings
DIR
2026-04-15 05:42:47
R
W
Run
Suggestions
DIR
2026-04-15 05:42:47
R
W
Run
WCPayPromotion
DIR
2026-04-15 05:42:47
R
W
Run
ActivityPanels.php
1.58 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Analytics.php
11.78 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
CategoryLookup.php
7.99 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Coupons.php
2.86 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
CouponsMovedTrait.php
2.41 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
CustomerEffortScoreTracks.php
17.65 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Events.php
8.66 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
FeaturePlugin.php
6.77 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Homescreen.php
8.65 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Loader.php
19.18 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Marketing.php
6.29 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Marketplace.php
3.48 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
MobileAppBanner.php
956 By
2026-04-15 05:42:46
R
W
Run
Delete
Rename
RemoteInboxNotifications.php
932 By
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Settings.php
14.57 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
ShippingLabelBanner.php
4.67 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
ShippingLabelBannerDisplayRules.php
3.63 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
SiteHealth.php
2.31 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
Survey.php
768 By
2026-04-15 05:42:47
R
W
Run
Delete
Rename
SystemStatusReport.php
5.85 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
Translations.php
11.66 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
WCAdminAssets.php
17.58 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
WCAdminSharedSettings.php
2.08 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
WCAdminUser.php
5.26 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
WcPayWelcomePage.php
6.33 KB
2026-04-15 05:42:47
R
W
Run
Delete
Rename
error_log
up
📄
Coupons.php
Save
<?php /** * WooCommerce Marketing > Coupons. */ namespace Automattic\WooCommerce\Internal\Admin; use Automattic\WooCommerce\Admin\Features\Features; use Automattic\WooCommerce\Admin\PageController; /** * Contains backend logic for the Coupons feature. */ class Coupons { use CouponsMovedTrait; /** * Class instance. * * @var Coupons instance */ protected static $instance = null; /** * Get class instance. */ public static function get_instance() { if ( ! self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Hook into WooCommerce. */ public function __construct() { if ( ! is_admin() ) { return; } // If the main marketing feature is disabled, don't modify coupon behavior. if ( ! Features::is_enabled( 'marketing' ) ) { return; } // Only support coupon modifications if coupons are enabled. if ( ! wc_coupons_enabled() ) { return; } add_action( 'admin_enqueue_scripts', array( $this, 'maybe_add_marketing_coupon_script' ) ); add_action( 'woocommerce_register_post_type_shop_coupon', array( $this, 'move_coupons' ) ); add_action( 'admin_head', array( $this, 'fix_coupon_menu_highlight' ), 99 ); add_action( 'admin_menu', array( $this, 'maybe_add_coupon_menu_redirect' ) ); } /** * Maybe add menu item back in original spot to help people transition */ public function maybe_add_coupon_menu_redirect() { if ( ! $this->should_display_legacy_menu() ) { return; } add_submenu_page( 'woocommerce', __( 'Coupons', 'woocommerce' ), __( 'Coupons', 'woocommerce' ), 'manage_options', 'coupons-moved', array( $this, 'coupon_menu_moved' ) ); } /** * Call back for transition menu item */ public function coupon_menu_moved() { wp_safe_redirect( $this->get_legacy_coupon_url(), 301 ); exit(); } /** * Modify registered post type shop_coupon * * @param array $args Array of post type parameters. * * @return array the filtered parameters. */ public function move_coupons( $args ) { $args['show_in_menu'] = current_user_can( 'manage_woocommerce' ) ? 'woocommerce-marketing' : true; return $args; } /** * Undo WC modifications to $parent_file for 'shop_coupon' */ public function fix_coupon_menu_highlight() { global $parent_file, $post_type; if ( $post_type === 'shop_coupon' ) { $parent_file = 'woocommerce-marketing'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride } } /** * Maybe add our wc-admin coupon scripts if viewing coupon pages */ public function maybe_add_marketing_coupon_script() { $curent_screen = PageController::get_instance()->get_current_page(); if ( ! isset( $curent_screen['id'] ) || $curent_screen['id'] !== 'woocommerce-coupons' ) { return; } WCAdminAssets::register_style( 'marketing-coupons', 'style' ); WCAdminAssets::register_script( 'wp-admin-scripts', 'marketing-coupons', true ); } }