get_settings(); if ( ! is_array( $sc_settings ) || empty( $sc_settings ) ) { return; } woocommerce_admin_fields( $sc_settings ); wp_nonce_field( 'wc_smart_coupons_settings', 'sc_security', false ); $this->sc_settings_page_styles_scripts(); } /** * Function to get Smart Coupons admin settings * * @return array $sc_settings Smart Coupons admin settings. */ public function get_settings() { global $store_credit_label; $singular = ( ! empty( $store_credit_label['singular'] ) ) ? $store_credit_label['singular'] : __( 'store credit', 'woocommerce-smart-coupons' ); $plural = ( ! empty( $store_credit_label['plural'] ) ) ? $store_credit_label['plural'] : __( 'store credits', 'woocommerce-smart-coupons' ); $valid_order_statuses = get_option( 'wc_sc_valid_order_statuses_for_coupon_auto_generation' ); $paid_statuses = wc_get_is_paid_statuses(); if ( false === $valid_order_statuses ) { add_option( 'wc_sc_valid_order_statuses_for_coupon_auto_generation', $paid_statuses, '', 'no' ); } elseif ( ! is_array( $valid_order_statuses ) ) { update_option( 'wc_sc_valid_order_statuses_for_coupon_auto_generation', $paid_statuses, 'no' ); } $all_order_statuses = wc_get_order_statuses(); $all_paid_order_statuses = array(); foreach ( $paid_statuses as $paid_status ) { $wc_paid_status = 'wc-' . $paid_status; if ( array_key_exists( $wc_paid_status, $all_order_statuses ) ) { $all_paid_order_statuses[ $paid_status ] = $all_order_statuses[ $wc_paid_status ]; } } $all_discount_types = wc_get_coupon_types(); $storewide_offer_coupon_option = array(); $storewide_offer_coupon_code = get_option( 'smart_coupons_storewide_offer_coupon_code' ); if ( ! empty( $storewide_offer_coupon_code ) ) { $coupon = new WC_Coupon( $storewide_offer_coupon_code ); $discount_type = ( is_object( $coupon ) && is_callable( array( $coupon, 'get_discount_type' ) ) ) ? $coupon->get_discount_type() : 'percent'; /* translators: 1. The coupon code, 2. The discount type */ $storewide_offer_coupon_option[ $storewide_offer_coupon_code ] = sprintf( __( '%1$s (Type: %2$s)', 'woocommerce-smart-coupons' ), $storewide_offer_coupon_code, ( ( array_key_exists( $discount_type, $all_discount_types ) ) ? $all_discount_types[ $discount_type ] : $discount_type ) ); } $valid_designs = $this->get_valid_coupon_designs(); $coupon_design = get_option( 'wc_sc_setting_coupon_design' ); $default_coupon_design = 'basic'; if ( ! empty( $coupon_design ) && 'custom-design' === $coupon_design ) { $default_coupon_design = $coupon_design; } $sc_settings = array( array( 'title' => __( 'Smart Coupons Settings', 'woocommerce-smart-coupons' ), 'type' => 'title', 'desc' => __( 'Set up Smart Coupons the way you like. Use these options to configure/change the way Smart Coupons works.', 'woocommerce-smart-coupons' ), 'id' => 'sc_display_coupon_settings', ), array( 'title' => __( 'Colors', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_setting_coupon_design_colors', 'default' => '2b2d42-edf2f4-d90429', 'type' => 'wc_sc_radio_with_html', 'desc_tip' => __( 'Choose a color scheme for coupons.', 'woocommerce-smart-coupons' ), 'class' => 'wc_sc_setting_coupon_design_colors', 'autoload' => false, 'options' => array( '2b2d42-edf2f4-d90429' => __( 'Amaranth red', 'woocommerce-smart-coupons' ), '003459-ffffff-00a8e8' => __( 'Carolina Blue', 'woocommerce-smart-coupons' ), '334752-fffdf5-46b39d' => __( 'Keppel', 'woocommerce-smart-coupons' ), 'edf2f4-bb2538-fcbf49' => __( 'McDonald', 'woocommerce-smart-coupons' ), 'd6b56d-231f20-ffe09c' => __( 'Gold', 'woocommerce-smart-coupons' ), '362f78-f8f9fa-5950ec' => __( 'Majorelle Blue', 'woocommerce-smart-coupons' ), 'a82f82-f5f8ff-f45dc4' => __( 'Rose Pink', 'woocommerce-smart-coupons' ), '2c5f72-f3d2b3-f16a6c' => __( 'Vintage', 'woocommerce-smart-coupons' ), 'e37332-fefefe-de4f3c' => __( 'Spanish Orange', 'woocommerce-smart-coupons' ), '8e6e5d-f2f2f2-333333' => __( 'Chocolate', 'woocommerce-smart-coupons' ), 'a7e7ff-418fde-ffffff' => __( 'Ocean', 'woocommerce-smart-coupons' ), ), 'args' => array( 'html_callback' => array( $this, 'color_scheme_html' ), ), ), array( 'title' => __( 'Customize colors', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_setting_coupon_design_colors', 'default' => 'custom', 'type' => 'wc_sc_radio_with_html', 'desc_tip' => __( 'Customize color scheme for coupons.', 'woocommerce-smart-coupons' ), 'class' => 'wc_sc_setting_coupon_design_colors custom', 'autoload' => false, 'options' => array( 'custom' => __( 'Custom colors', 'woocommerce-smart-coupons' ), ), 'args' => array( 'html_callback' => array( $this, 'color_scheme_html' ), ), ), array( 'title' => __( 'Styles', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_setting_coupon_design', 'default' => $default_coupon_design, 'type' => 'wc_sc_radio_with_html', 'desc_tip' => __( 'Choose a style for coupon on the website.', 'woocommerce-smart-coupons' ), 'class' => 'sc-coupons-list wc_sc_setting_coupon_design', 'autoload' => false, 'options' => array( 'flat' => __( 'Flat', 'woocommerce-smart-coupons' ), 'promotion' => __( 'Promotion', 'woocommerce-smart-coupons' ), 'ticket' => __( 'Ticket', 'woocommerce-smart-coupons' ), 'festive' => __( 'Festive', 'woocommerce-smart-coupons' ), 'special' => __( 'Special', 'woocommerce-smart-coupons' ), 'shipment' => __( 'Shipment', 'woocommerce-smart-coupons' ), 'cutout' => __( 'Cutout', 'woocommerce-smart-coupons' ), 'deliver' => __( 'Deliver', 'woocommerce-smart-coupons' ), 'clipper' => __( 'Clipper', 'woocommerce-smart-coupons' ), 'basic' => __( 'Basic', 'woocommerce-smart-coupons' ), 'deal' => __( 'Deal', 'woocommerce-smart-coupons' ), ), 'args' => array( 'html_callback' => array( $this, 'coupon_design_html' ), ), ), array( 'title' => __( 'Style for email', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_setting_coupon_design_for_email', 'default' => 'email-coupon', 'type' => 'wc_sc_radio_with_html', 'desc_tip' => __( 'Style for coupon in email.', 'woocommerce-smart-coupons' ), 'class' => 'sc-coupons-list wc_sc_setting_coupon_design', 'autoload' => false, 'options' => array( 'email-coupon' => __( 'Email coupon', 'woocommerce-smart-coupons' ), ), 'args' => array( 'html_callback' => array( $this, 'coupon_design_html' ), ), ), array( 'name' => __( 'Number of coupons to show', 'woocommerce-smart-coupons' ), 'desc' => __( 'How many coupons (at max) should be shown on cart, checkout & my account page? If set to 0 (zero) then coupons will not be displayed at all on the website.', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_setting_max_coupon_to_show', 'type' => 'number', 'desc_tip' => true, 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'name' => __( 'Number of characters in auto-generated coupon code', 'woocommerce-smart-coupons' ), 'desc' => __( 'Number of characters in auto-generated coupon code will be restricted to this number excluding prefix and/or suffix. The default length will be 13. It is recommended to keep this number between 10 to 15 to avoid coupon code duplication.', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_coupon_code_length', 'type' => 'number', 'desc_tip' => true, 'placeholder' => '13', 'css' => 'min-width:300px;', 'custom_attributes' => array( 'min' => 7, 'step' => 1, 'max' => 20, ), 'autoload' => false, ), array( 'name' => __( 'Valid order status for auto-generating coupon', 'woocommerce-smart-coupons' ), 'desc' => __( 'Choose order status which will trigger the auto-generation of coupon, if the order contains product which will generate the coupon.', 'woocommerce-smart-coupons' ), 'id' => 'wc_sc_valid_order_statuses_for_coupon_auto_generation', 'default' => $paid_statuses, 'type' => 'multiselect', 'class' => 'wc-enhanced-select', 'css' => 'min-width: 350px;', 'desc_tip' => true, 'options' => $all_paid_order_statuses, 'custom_attributes' => array( 'data-placeholder' => __( 'Select order status…', 'woocommerce-smart-coupons' ), ), 'autoload' => false, ), array( 'name' => __( 'Enable store notice for the coupon', 'woocommerce-smart-coupons' ), 'id' => 'smart_coupons_storewide_offer_coupon_code', 'type' => 'select', 'default' => '', 'desc' => __( 'Search & select a coupon which you want to display as store notice. The selected coupon\'s description will be displayed along with the coupon code (if it is set) otherwise, a description will be generated automatically. To disable the feature, keep this field empty.', 'woocommerce-smart-coupons' ), 'desc_tip' => true, 'class' => 'wc-sc-storewide-coupon-search', 'css' => 'min-width:300px;', 'autoload' => false, 'custom_attributes' => array( 'data-placeholder' => __( 'Search for a coupon...', 'woocommerce-smart-coupons' ), 'data-action' => 'sc_json_search_storewide_coupons', 'data-security' => wp_create_nonce( 'search-coupons' ), 'data-allow_clear' => true, ), 'options' => $storewide_offer_coupon_option, ), array( /* translators: %s: Label for store credit */ 'name' => sprintf( __( 'Generated %s amount', 'woocommerce-smart-coupons' ), strtolower( $singular ) ), /* translators: %s: Label for store credit */ 'desc' => sprintf( __( 'Include tax in the amount of the generated %s', 'woocommerce-smart-coupons' ), strtolower( $singular ) ), 'id' => 'wc_sc_generated_store_credit_includes_tax', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => 'start', 'autoload' => false, ), array( 'name' => __( 'Displaying coupons', 'woocommerce-smart-coupons' ), /* translators: %s: Preview link */ 'desc' => sprintf( __( 'Include coupon details on product\'s page, for products that issue coupons %s', 'woocommerce-smart-coupons' ), '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'smart_coupons_is_show_associated_coupons', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => 'start', 'autoload' => false, ), array( /* translators: %s: Preview link */ 'desc' => sprintf( __( 'Show coupons available to customers on their My Account > Coupons page %s', 'woocommerce-smart-coupons' ), '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'woocommerce_smart_coupon_show_my_account', 'type' => 'checkbox', 'default' => 'yes', 'checkboxgroup' => '', 'autoload' => false, ), array( /* translators: %s: Preview link */ 'desc' => sprintf( __( 'Include coupons received from other people on My Account > Coupons page %s', 'woocommerce-smart-coupons' ), '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'show_coupon_received_on_my_account', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => '', 'autoload' => false, ), array( /* translators: %s: Preview link */ 'desc' => sprintf( __( 'Show invalid or used coupons in My Account > Coupons %s', 'woocommerce-smart-coupons' ), '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'smart_coupons_show_invalid_coupons_on_myaccount', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => '', 'autoload' => false, ), array( /* translators: %s: Preview link */ 'desc' => sprintf( __( 'Display coupon description along with coupon code (on site as well as in emails) %s', 'woocommerce-smart-coupons' ), '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'smart_coupons_show_coupon_description', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => 'end', 'autoload' => false, ), array( 'name' => __( 'Auto apply coupons', 'woocommerce-smart-coupons' ), /* translators: %s: Explanation of the setting */ 'desc' => sprintf( __( 'When enabled, each coupon will have the option to enable auto-apply for that coupon %s', 'woocommerce-smart-coupons' ), '
' . __( 'Disabling this, no coupons will be auto-applied - even if any coupon has "Auto apply?" enabled.', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'wc_sc_allow_auto_apply', 'type' => 'checkbox', 'default' => 'yes', 'checkboxgroup' => 'start', 'autoload' => false, ), array( 'name' => __( 'Automatic deletion', 'woocommerce-smart-coupons' ), /* translators: %s: Note for admin */ 'desc' => sprintf( __( 'Delete the %1$s when entire credit amount is used up %2$s', 'woocommerce-smart-coupons' ), strtolower( $singular ), '' . __( '(Note: It\'s recommended to keep it Disabled)', 'woocommerce-smart-coupons' ) . '' ), 'id' => 'woocommerce_delete_smart_coupon_after_usage', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => 'start', 'autoload' => false, ), array( 'name' => __( 'Coupon emails', 'woocommerce-smart-coupons' ), 'desc' => __( 'Email auto generated coupons to recipients', 'woocommerce-smart-coupons' ), 'id' => 'smart_coupons_is_send_email', 'type' => 'checkbox', 'default' => 'yes', 'checkboxgroup' => 'start', 'autoload' => false, ), array( 'name' => __( 'Printing coupons', 'woocommerce-smart-coupons' ), 'desc' => __( 'Enable feature to allow printing of coupons', 'woocommerce-smart-coupons' ) . ' ' . __( '[Read More]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupons_is_print_coupon', 'type' => 'checkbox', 'default' => 'yes', 'checkboxgroup' => 'start', 'autoload' => false, ), array( /* translators: %s: Label for store credit */ 'name' => sprintf( __( 'Sell %s at less price?', 'woocommerce-smart-coupons' ), strtolower( $plural ) ), /* translators: %s: Label for store credit, 1: : Label for store credit, 2: Label for store credit, 3: Label for store credit */ 'desc' => sprintf( __( 'Allow selling %s at discounted price', 'woocommerce-smart-coupons' ), strtolower( $plural ) ) . ' ' . __( '[Read More]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupons_sell_store_credit_at_less_price', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'default' => 'no', 'autoload' => false, 'desc_tip' => '', ), array( 'type' => 'sectionend', 'id' => 'sc_display_coupon_settings', ), array( 'title' => __( 'Labels', 'woocommerce-smart-coupons' ), 'type' => 'title', 'desc' => __( 'Call it something else! Use these to quickly change text labels through your store. Use translations for complete control.', 'woocommerce-smart-coupons' ), 'id' => 'sc_setting_labels', ), array( 'name' => __( 'Store Credit / Gift Certificate', 'woocommerce-smart-coupons' ), 'desc' => '' . __( '[Read More]', 'woocommerce-smart-coupons' ) . '', 'id' => 'sc_store_credit_singular_text', 'type' => 'text', 'placeholder' => __( 'Singular name', 'woocommerce-smart-coupons' ), 'desc_tip' => __( 'Give alternate singular name to Store Credit / Gift Certificate. This label will only rename Store Credit / Gift Certificate used in the Smart Coupons plugin.', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'id' => 'sc_store_credit_plural_text', 'type' => 'text', 'desc_tip' => __( 'Give plural name for the above singular name.', 'woocommerce-smart-coupons' ), 'placeholder' => __( 'Plural name', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( /* translators: %s: Label for store credit */ 'name' => sprintf( __( '%s product CTA', 'woocommerce-smart-coupons' ), ucfirst( $singular ) ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'sc_gift_certificate_shop_loop_button_text', 'type' => 'text', /* translators: %s: Label for store credit */ 'desc_tip' => sprintf( __( 'This is what will be shown instead of "Add to Cart" for products that sell %s.', 'woocommerce-smart-coupons' ), strtolower( $plural ) ), 'placeholder' => __( 'Select options', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( /* translators: %s: Label for store credit */ 'name' => sprintf( __( 'While purchasing %s', 'woocommerce-smart-coupons' ), strtolower( $plural ) ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupon_store_gift_page_text', 'type' => 'text', /* translators: %s: Label for store credit */ 'desc_tip' => sprintf( __( 'When you opt to allow people to buy %s of any amount, this label will be used.', 'woocommerce-smart-coupons' ), strtolower( $plural ) ), 'placeholder' => __( 'Purchase credit worth', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'name' => __( '"Coupons with Product" description', 'woocommerce-smart-coupons' ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupon_product_page_text', 'type' => 'text', 'desc_tip' => __( 'This is the heading above coupon details displayed on products that issue coupons.', 'woocommerce-smart-coupons' ), 'placeholder' => __( 'You will get following coupon(s) when you buy this item', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'name' => __( 'On Cart/Checkout pages', 'woocommerce-smart-coupons' ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupon_cart_page_text', 'type' => 'text', 'desc_tip' => __( 'This is the title for the list of available coupons, shown on Cart and Checkout pages.', 'woocommerce-smart-coupons' ), 'placeholder' => __( 'Available Coupons (click on a coupon to use it)', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'name' => __( 'My Account page', 'woocommerce-smart-coupons' ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupon_myaccount_page_text', 'type' => 'text', 'desc_tip' => __( 'Title of available coupons list on My Account page.', 'woocommerce-smart-coupons' ), /* translators: %s: Label for store credit */ 'placeholder' => sprintf( __( 'Available Coupons & %s', 'woocommerce-smart-coupons' ), ucwords( $plural ) ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'type' => 'sectionend', 'id' => 'sc_setting_labels', ), array( 'title' => __( 'Coupon Receiver Details during Checkout', 'woocommerce-smart-coupons' ), 'type' => 'title', 'desc' => __( 'Buyers can send purchased coupons to anyone – right while they\'re checking out.', 'woocommerce-smart-coupons' ), 'id' => 'sc_coupon_receiver_settings', ), array( 'name' => __( 'Allow sending of coupons to others', 'woocommerce-smart-coupons' ), 'desc' => __( 'Allow the buyer to send coupons to someone else.', 'woocommerce-smart-coupons' ) . ' ' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupons_display_coupon_receiver_details_form', 'type' => 'checkbox', 'default' => 'yes', 'autoload' => false, 'desc_tip' => '', ), array( 'name' => __( 'Title', 'woocommerce-smart-coupons' ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupon_gift_certificate_form_page_text', 'type' => 'text', 'desc_tip' => __( 'The title for coupon receiver details block.', 'woocommerce-smart-coupons' ), 'placeholder' => __( 'Send Coupons to...', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'name' => __( 'Description', 'woocommerce-smart-coupons' ), 'desc' => '' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupon_gift_certificate_form_details_text', 'type' => 'text', 'desc_tip' => __( 'Additional text below the title.', 'woocommerce-smart-coupons' ), 'css' => 'min-width:300px;', 'autoload' => false, ), array( 'name' => __( 'Allow schedule sending of coupons?', 'woocommerce-smart-coupons' ), 'desc' => __( 'Enable this to allow buyers to select date & time for delivering the coupon.', 'woocommerce-smart-coupons' ) . ' ' . __( '[Preview]', 'woocommerce-smart-coupons' ) . '', 'id' => 'smart_coupons_schedule_store_credit', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'default' => 'no', 'autoload' => false, 'desc_tip' => '', ), array( 'name' => __( 'Combine emails', 'woocommerce-smart-coupons' ), 'desc' => __( 'Send only one email instead of multiple emails when multiple coupons are generated for same recipient', 'woocommerce-smart-coupons' ), 'id' => 'smart_coupons_combine_emails', 'type' => 'checkbox', 'default' => 'no', 'autoload' => false, ), array( 'type' => 'sectionend', 'id' => 'sc_coupon_receiver_settings', ), ); if ( $this->is_wc_gte_30() && wc_tax_enabled() ) { $before_tax_option[] = array( 'name' => __( 'Apply before tax', 'woocommerce-smart-coupons' ), 'desc' => __( 'Deduct credit/gift before doing tax calculations', 'woocommerce-smart-coupons' ), 'id' => 'woocommerce_smart_coupon_apply_before_tax', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => 'start', 'autoload' => false, 'show_if_checked' => 'option', ); $prices_include_tax = wc_prices_include_tax(); if ( true === $prices_include_tax ) { $before_tax_option[] = array( /* translators: %s: Label for store credit */ 'name' => sprintf( __( '%s include tax?', 'woocommerce-smart-coupons' ), ucfirst( $singular ) ), /* translators: %s: Label for store credit */ 'desc' => sprintf( __( '%s discount is inclusive of tax', 'woocommerce-smart-coupons' ), ucfirst( $singular ) ), 'id' => 'woocommerce_smart_coupon_include_tax', 'type' => 'checkbox', 'default' => 'no', 'checkboxgroup' => 'end', 'autoload' => false, 'show_if_checked' => 'yes', ); } array_splice( $sc_settings, 15, 0, $before_tax_option ); } return apply_filters( 'wc_smart_coupons_settings', $sc_settings ); } /** * Function for saving settings for Gift Certificate */ public function save_smart_coupon_admin_settings() { if ( empty( $_POST['sc_security'] ) || ! wp_verify_nonce( wp_unslash( $_POST['sc_security'] ), 'wc_smart_coupons_settings' ) ) { // phpcs:ignore return; } $sc_settings = $this->get_settings(); if ( ! is_array( $sc_settings ) || empty( $sc_settings ) ) { return; } woocommerce_update_options( $sc_settings ); // Update WC Email settings when SC admin settings are updated. $is_send_email = get_option( 'smart_coupons_is_send_email', 'yes' ); $combine_emails = get_option( 'smart_coupons_combine_emails', 'no' ); $email_settings = get_option( 'woocommerce_wc_sc_email_coupon_settings', array() ); if ( is_array( $email_settings ) ) { $email_settings['enabled'] = $is_send_email; update_option( 'woocommerce_wc_sc_email_coupon_settings', $email_settings, 'no' ); } $combine_email_settings = get_option( 'woocommerce_wc_sc_combined_email_coupon_settings', array() ); if ( is_array( $combine_email_settings ) ) { $combine_email_settings['enabled'] = $combine_emails; update_option( 'woocommerce_wc_sc_combined_email_coupon_settings', $combine_email_settings, 'no' ); } $predefined_colors = array( '2b2d42-edf2f4-d90429', '003459-ffffff-00a8e8', '334752-fffdf5-46b39d', 'edf2f4-bb2538-fcbf49', 'd6b56d-231f20-ffe09c', '362f78-f8f9fa-5950ec', 'a82f82-f5f8ff-f45dc4', '2c5f72-f3d2b3-f16a6c', 'e37332-fefefe-de4f3c', '8e6e5d-f2f2f2-333333', 'a7e7ff-418fde-ffffff', ); $color_options = array( 'wc_sc_setting_coupon_background_color', 'wc_sc_setting_coupon_foreground_color', 'wc_sc_setting_coupon_third_color', ); $colors = array(); foreach ( $color_options as $option ) { $post_option = ( isset( $_POST[ $option ] ) ) ? wc_clean( wp_unslash( $_POST[ $option ] ) ) : ''; // phpcs:ignore if ( ! empty( $post_option ) ) { $colors[] = $post_option; update_option( $option, $post_option, 'no' ); } } $color_scheme = implode( '-', $colors ); $color_scheme = str_replace( '#', '', $color_scheme ); if ( in_array( $color_scheme, $predefined_colors, true ) ) { update_option( 'wc_sc_setting_coupon_design_colors', $color_scheme, 'no' ); } $old_storewide_offer_coupon_code = get_option( 'smart_coupons_storewide_offer_coupon_code' ); $post_storewide_offer_coupon_code = ( ! empty( $_POST['smart_coupons_storewide_offer_coupon_code'] ) ) ? wc_clean( wp_unslash( $_POST['smart_coupons_storewide_offer_coupon_code'] ) ) : ''; // phpcs:ignore if ( $old_storewide_offer_coupon_code !== $post_storewide_offer_coupon_code ) { update_option( 'smart_coupons_storewide_offer_coupon_code', $post_storewide_offer_coupon_code, 'no' ); if ( ! empty( $post_storewide_offer_coupon_code ) ) { $coupon_id = wc_get_coupon_id_by_code( $post_storewide_offer_coupon_code ); $coupon = new WC_Coupon( $coupon_id ); $coupon_status = ( $this->is_wc_greater_than( '6.1.2' ) && $this->is_callable( $coupon, 'get_status' ) ) ? $coupon->get_status() : get_post_status( $coupon_id ); if ( 'publish' === $coupon_status ) { update_option( 'woocommerce_demo_store', 'yes' ); } else { update_option( 'woocommerce_demo_store', 'no' ); } update_option( 'woocommerce_demo_store_notice', '', 'no' ); $notice = get_option( 'woocommerce_demo_store_notice' ); if ( empty( $notice ) ) { $coupon = new WC_Coupon( $post_storewide_offer_coupon_code ); $notice = $this->generate_storewide_offer_coupon_description( array( 'coupon_object' => $coupon ) ); update_option( 'woocommerce_demo_store_notice', wp_filter_post_kses( $notice ), 'no' ); } } else { update_option( 'woocommerce_demo_store', 'no' ); update_option( 'woocommerce_demo_store_notice', '', 'no' ); } } } /** * Function to Add Delete Credit After Usage Notice */ public function add_delete_credit_after_usage_notice() { $is_delete_smart_coupon_after_usage = get_option( 'woocommerce_delete_smart_coupon_after_usage' ); if ( 'yes' !== $is_delete_smart_coupon_after_usage ) { return; } $admin_email = get_option( 'admin_email' ); $user = get_user_by( 'email', $admin_email ); $current_user_id = get_current_user_id(); if ( ! empty( $current_user_id ) && ! empty( $user->ID ) && $current_user_id === $user->ID ) { add_action( 'admin_notices', array( $this, 'delete_credit_after_usage_notice' ) ); add_action( 'admin_footer', array( $this, 'ignore_delete_credit_after_usage_notice' ) ); } } /** * Function to Delete Credit After Usage Notice */ public function delete_credit_after_usage_notice() { global $store_credit_label; $plural = ( ! empty( $store_credit_label['plural'] ) ) ? $store_credit_label['plural'] : __( 'store credits', 'woocommerce-smart-coupons' ); $current_user_id = get_current_user_id(); $is_hide_delete_after_usage_notice = get_user_meta( $current_user_id, 'hide_delete_credit_after_usage_notice', true ); // @codingStandardsIgnoreLine if ( 'yes' !== $is_hide_delete_after_usage_notice ) { echo '

'; if ( ! empty( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && empty( $_GET['tab'] ) ) { // phpcs:ignore /* translators: 1: plugin name 2: page based text 3: Label for store credit 4: Hide notice text */ echo sprintf( esc_html__( '%1$s: %2$s to avoid issues related to missing data for %3$s. %4$s', 'woocommerce-smart-coupons' ), '' . esc_html__( 'WooCommerce Smart Coupons', 'woocommerce-smart-coupons' ) . '', esc_html__( 'Uncheck', 'woocommerce-smart-coupons' ) . ' "' . esc_html__( 'Delete Gift / Credit, when credit is used up', 'woocommerce-smart-coupons' ) . '"', esc_html( strtolower( $plural ) ), '' . esc_html__( 'Setting', 'woocommerce-smart-coupons' ) . '' ) . ' '; // phpcs ignore. } else { /* translators: 1: plugin name 2: page based text 3: Label for store credit 4: Hide notice text */ echo sprintf( esc_html__( '%1$s: %2$s to avoid issues related to missing data for %3$s. %4$s', 'woocommerce-smart-coupons' ), '' . esc_html__( 'WooCommerce Smart Coupons', 'woocommerce-smart-coupons' ) . '', '' . esc_html__( 'Important setting', 'woocommerce-smart-coupons' ) . '', esc_html( strtolower( $plural ) ), '' . esc_html__( 'Setting', 'woocommerce-smart-coupons' ) . '' ) . ' '; // phpcs ignore. } echo '

'; } } /** * Function to Ignore Delete Credit After Usage Notice */ public function ignore_delete_credit_after_usage_notice() { if ( ! wp_script_is( 'jquery' ) ) { wp_enqueue_script( 'jquery' ); } ?> $attribute_value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; } } $field_description = WC_Admin_Settings::get_field_description( $value ); $description = $field_description['description']; $tooltip_html = $field_description['tooltip_html']; $option_value = $value['value']; ?>
'#39cccc', 'wc_sc_setting_coupon_foreground_color' => '#30050b', 'wc_sc_setting_coupon_third_color' => '#39cccc', ); foreach ( $color_options as $option => $default ) { $color_code = get_option( $option, $default ); ?> 10, 'amount_symbol' => get_woocommerce_currency_symbol(), 'discount_type' => __( 'Discount', 'woocommerce-smart-coupons' ), 'coupon_description' => __( 'Hurry. Going fast! On the entire range of products.', 'woocommerce-smart-coupons' ), 'coupon_code' => 'sample-code', 'coupon_expiry' => $this->get_expiration_format( $this->strtotime( 'Dec 31' ) ), 'thumbnail_src' => $this->get_coupon_design_thumbnail_src(), 'classes' => '', 'template_id' => $design, 'is_percent' => false, ); ?>