|
@@ -10,10 +10,11 @@
|
|
|
* Author URI: https://www.quadarax.com
|
|
* Author URI: https://www.quadarax.com
|
|
|
* License: GPL v2 or later
|
|
* License: GPL v2 or later
|
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
- * Text Domain: studiou-wc-product-cat-manage
|
|
|
|
|
|
|
+ * Text Domain: studiou-wc-mandatory-products
|
|
|
* Domain Path: /languages
|
|
* Domain Path: /languages
|
|
|
* WC requires at least: 3.0
|
|
* WC requires at least: 3.0
|
|
|
* WC tested up to: 8.0
|
|
* WC tested up to: 8.0
|
|
|
|
|
+ * Woo: 12345:a123b456c789d0
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
// Exit if accessed directly
|
|
// Exit if accessed directly
|
|
@@ -26,6 +27,17 @@ if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Declare HPOS compatibility
|
|
|
|
|
+add_action('before_woocommerce_init', function() {
|
|
|
|
|
+ if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) {
|
|
|
|
|
+ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
|
|
|
|
|
+ 'custom_order_tables',
|
|
|
|
|
+ __FILE__,
|
|
|
|
|
+ true
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
if (!class_exists('StudioU_WC_Mandatory_Products')) {
|
|
if (!class_exists('StudioU_WC_Mandatory_Products')) {
|
|
|
|
|
|
|
|
class StudioU_WC_Mandatory_Products {
|
|
class StudioU_WC_Mandatory_Products {
|
|
@@ -79,8 +91,8 @@ if (!class_exists('StudioU_WC_Mandatory_Products')) {
|
|
|
// Frontend hooks
|
|
// Frontend hooks
|
|
|
add_action('init', array($this, 'init_frontend'), 10);
|
|
add_action('init', array($this, 'init_frontend'), 10);
|
|
|
|
|
|
|
|
- // Add mandatory products to cart
|
|
|
|
|
- add_action('woocommerce_add_to_cart', array($this, 'add_mandatory_products_to_cart'), 10, 6);
|
|
|
|
|
|
|
+ // Add mandatory products to cart (with priority to ensure it runs after WooCommerce's own handlers)
|
|
|
|
|
+ add_action('woocommerce_add_to_cart', array($this, 'add_mandatory_products_to_cart'), 20, 6);
|
|
|
|
|
|
|
|
// Display mandatory products info on product page
|
|
// Display mandatory products info on product page
|
|
|
add_action('woocommerce_before_add_to_cart_button', array($this, 'display_mandatory_products_info'), 10);
|
|
add_action('woocommerce_before_add_to_cart_button', array($this, 'display_mandatory_products_info'), 10);
|