Server IP : 192.158.238.246 / Your IP : 3.129.73.179 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/task/7779/cwd/plugins/woocommerce/includes/ |
Upload File : |
<?php //phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps declare( strict_types = 1); /** * Brand settings manager. * * This class is responsible for setting and getting brand settings for a coupon. * * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. * * @version 9.4.0 */ class WC_Brands_Brand_Settings_Manager { /** * Brand settings for a coupon. * * @var array */ private static $brand_settings = array(); /** * Set brand settings for a coupon. * * @param WC_Coupon $coupon Coupon object. */ public static function set_brand_settings_on_coupon( $coupon ) { $coupon_id = $coupon->get_id(); // Check if the brand settings are already set for this coupon. if ( isset( self::$brand_settings[ $coupon_id ] ) ) { return; } $included_brands = get_post_meta( $coupon_id, 'product_brands', true ); $included_brands = ! empty( $included_brands ) ? $included_brands : array(); $excluded_brands = get_post_meta( $coupon_id, 'exclude_product_brands', true ); $excluded_brands = ! empty( $excluded_brands ) ? $excluded_brands : array(); // Store these settings in the static array. self::$brand_settings[ $coupon_id ] = array( 'included_brands' => $included_brands, 'excluded_brands' => $excluded_brands, ); } /** * Get brand settings for a coupon. * * @param WC_Coupon $coupon Coupon object. * @return array Brand settings (included and excluded brands). */ public static function get_brand_settings_on_coupon( $coupon ) { $coupon_id = $coupon->get_id(); if ( isset( self::$brand_settings[ $coupon_id ] ) ) { return self::$brand_settings[ $coupon_id ]; } // Default return value if no settings are found. return array( 'included_brands' => array(), 'excluded_brands' => array(), ); } }