Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/dc-woocommerce-multi-vendor/assets/js/block/follow-store/view.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/follow-store/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '3d6046a7a9ecfd9db1c0');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '750546ac627258f3882d');
--- a/dc-woocommerce-multi-vendor/assets/js/block/marketplace-coupons/index.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/marketplace-coupons/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '35c860cd7c2955a59b0a');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'dd4c19a76fba76dc6652');
--- a/dc-woocommerce-multi-vendor/assets/js/block/marketplace-products/index.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/marketplace-products/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '655440f6d3db434aa2da');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '29b4bba6f55933660925');
--- a/dc-woocommerce-multi-vendor/assets/js/block/marketplace-stores/index.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/marketplace-stores/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-polyfill'), 'version' => '73cca8cb04e539378236');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-polyfill'), 'version' => '63a71d6fb2e6f7b337a8');
--- a/dc-woocommerce-multi-vendor/assets/js/block/marketplace-stores/view.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/marketplace-stores/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '0fbf8b19f7bcaec23d3c');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '5a3c9de1918e467e445f');
--- a/dc-woocommerce-multi-vendor/assets/js/block/registration-form/index.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/registration-form/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-polyfill'), 'version' => 'f20970627404ae9fc32e');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-polyfill'), 'version' => '83f0e9fdaa29853d33e6');
--- a/dc-woocommerce-multi-vendor/assets/js/block/registration-form/view.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/registration-form/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'c2e974ca4d40ec802e4e');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'd168b88648109e064eb5');
--- a/dc-woocommerce-multi-vendor/assets/js/block/setup-wizard/index.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/setup-wizard/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '473544fca6ce87736c2d');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'b1de9557a2b9044a3e86');
--- a/dc-woocommerce-multi-vendor/assets/js/block/store-quick-info/view.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/store-quick-info/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '5c529cdaa5daf459c120');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '77c827a9a7589af5e4ae');
--- a/dc-woocommerce-multi-vendor/assets/js/block/store-review/view.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/block/store-review/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '297e9c1c8a414d7c1306');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '1bc612d56a880704033e');
--- a/dc-woocommerce-multi-vendor/assets/js/index.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '520cd5cb4eb67536d3db');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '0a6a899b53c769c6ffcd');
--- a/dc-woocommerce-multi-vendor/assets/js/vendors.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/js/vendors.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-polyfill'), 'version' => '51afc6ac22d33261e1cf');
+<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'caac585635d46fb15386');
--- a/dc-woocommerce-multi-vendor/assets/modules/StoreShipping/block/view.asset.php
+++ b/dc-woocommerce-multi-vendor/assets/modules/StoreShipping/block/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-i18n', 'wp-polyfill'), 'version' => 'aeb4984bf1f13e6ab201');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-i18n', 'wp-polyfill'), 'version' => '281519c910aeabc4b459');
--- a/dc-woocommerce-multi-vendor/classes/Order/Hooks.php
+++ b/dc-woocommerce-multi-vendor/classes/Order/Hooks.php
@@ -176,10 +176,11 @@
return;
}
- MultiVendorX()->order->create_store_orders( $order );
-
- $order->update_meta_data( Utill::ORDER_META_SETTINGS['has_sub_order'], true );
- $order->save();
+ $store_order = MultiVendorX()->order->create_store_orders( $order );
+ if( $store_order ){
+ $order->update_meta_data( Utill::ORDER_META_SETTINGS['has_sub_order'], true );
+ $order->save();
+ }
}
/**
--- a/dc-woocommerce-multi-vendor/classes/Order/OrderManager.php
+++ b/dc-woocommerce-multi-vendor/classes/Order/OrderManager.php
@@ -133,7 +133,7 @@
}
}
}
-
+ $create_or_update =false;
foreach ( $item_info as $store_id => $items ) {
if ( in_array( $store_id, $existing_orders, true ) ) {
$suborder_ids = array_keys( $existing_orders, $store_id, true );
@@ -147,6 +147,7 @@
}
$store_order->save();
+ $create_or_update =true;
$store = new Store( $store_id );
if ( ! $store->exists() ) {
continue;
@@ -161,6 +162,7 @@
)
);
}
+ return $create_or_update;
}
/**
--- a/dc-woocommerce-multi-vendor/classes/Payments/StripeConnect.php
+++ b/dc-woocommerce-multi-vendor/classes/Payments/StripeConnect.php
@@ -277,11 +277,13 @@
* Create Stripe account
*/
public function connect_stripe() {
- check_admin_referer( 'multivendorx_connect_stripe' );
if ( ! is_user_logged_in() ) {
return false;
}
+ $store_id = MultiVendorX()->active_store;
+ if( empty( $store_id )) return false;
+
$config = $this->get_store_stripe_config();
$store = $config['store'];
if ( empty( $store ) ) {
@@ -382,7 +384,8 @@
return;
}
- check_admin_referer( 'multivendorx_disconnect_stripe' );
+ $store_id = MultiVendorX()->active_store;
+ if( empty( $store_id )) return false;
$config = $this->get_store_stripe_config();
$store = $config['store'];
--- a/dc-woocommerce-multi-vendor/classes/RestAPI/Controllers/Commissions.php
+++ b/dc-woocommerce-multi-vendor/classes/RestAPI/Controllers/Commissions.php
@@ -10,6 +10,7 @@
use MultiVendorXCommissionCommissionUtil;
use MultiVendorXUtill;
use MultiVendorXStoreStore;
+use MultiVendorXStoreStoreUtil;
defined( 'ABSPATH' ) || exit;
@@ -113,6 +114,14 @@
$format = $request->get_param( 'format' );
$order_id = $request->get_param( 'order_id' );
+ if ( ! StoreUtil::current_user_can_manage_store( $store_id ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to view this store's commissions.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
if ( 'reports' === $format ) {
$top_stores = $request->get_param( 'top_stores' );
$dashboard = $request->get_param( 'dashboard' );
@@ -297,7 +306,24 @@
try {
$id = absint( $request->get_param( 'id' ) );
$commission = reset( CommissionUtil::get_commission_information( array( 'ID' => $id ) ) );
- $data = $this->prepare_item_for_response( $commission, true );
+
+ if ( ! $commission ) {
+ return new WP_Error(
+ 'rest_not_found',
+ __( 'Commission not found.', 'multivendorx' ),
+ array( 'status' => 404 )
+ );
+ }
+
+ if ( ! StoreUtil::current_user_can_manage_store( $commission['store_id'] ?? 0 ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to view this commission.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
+ $data = $this->prepare_item_for_response( $commission, true );
return rest_ensure_response( $data );
} catch ( Exception $e ) {
@@ -334,6 +360,14 @@
$action = $request->get_param( 'action' );
if ( 'regenerate' === $action ) {
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to regenerate commissions.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
$order = wc_get_order( $order_id );
if ( $order ) {
MultiVendorX()->order->admin->regenerate_order_commissions( $order );
--- a/dc-woocommerce-multi-vendor/classes/RestAPI/Controllers/Stores.php
+++ b/dc-woocommerce-multi-vendor/classes/RestAPI/Controllers/Stores.php
@@ -80,7 +80,7 @@
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_states_by_country' ),
- 'permission_callback' => array( $this, 'get_items_permissions_check' ),
+ 'permission_callback' => '__return_true',
)
);
}
@@ -91,7 +91,7 @@
* @param object $request Request data.
*/
public function get_items_permissions_check( $request ) {
- return true;
+ return current_user_can( 'manage_options' ) || current_user_can( 'edit_stores' );
}
/**
@@ -350,6 +350,11 @@
$store_meta = Store::get_store( $store_id );
$owner_id = StoreUtil::get_primary_owner( $store_id );
$owner = get_userdata( $owner_id );
+ $owner_data = array(
+ 'id' => $owner->ID,
+ 'display_name' => $owner->display_name,
+ 'user_email' => $owner->user_email,
+ );
$formatted_stores[] = apply_filters(
'multivendorx_stores_details',
array(
@@ -359,7 +364,7 @@
'status' => $store['status'],
'email' => $store_meta->meta_data[ Utill::STORE_SETTINGS_KEYS['store_email'] ]['primary'] ?? '',
'phone' => $store_meta->meta_data[ Utill::STORE_SETTINGS_KEYS['phone'] ] ?? '',
- 'primary_owner' => $owner,
+ 'primary_owner' => $owner_data,
'primary_owner_image' => get_avatar_url( $owner_id, 48 ),
'create_time' => Utill::multivendorx_rest_prepare_date_response( $store['create_time'] ),
'create_time_gmt' => Utill::multivendorx_rest_prepare_date_response( $store['create_time'], true ),
@@ -755,6 +760,14 @@
$start_date = $request->get_param( 'start_date' );
$end_date = $request->get_param( 'end_date' );
+ if ( $id && ! StoreUtil::current_user_can_manage_store( $id ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to access this store.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
if ( $id && 'switch' === $action ) {
update_user_meta(
MultiVendorX()->current_user_id,
@@ -778,9 +791,12 @@
}
$primary_owner_id = StoreUtil::get_primary_owner( $id );
- $primary_owner_info = $primary_owner_id
- ? get_userdata( $primary_owner_id )
- : null;
+ $owner = get_userdata( $primary_owner_id );
+ $primary_owner_info = array(
+ 'id' => $owner->ID,
+ 'display_name' => $owner->display_name,
+ 'user_email' => $owner->user_email,
+ );
if ( $fetch_user ) {
$users = StoreUtil::get_store_users( $id );
@@ -905,6 +921,14 @@
$status = $request->get_param( 'action' );
if ( ! empty( $ids ) && ! empty( $status ) ) {
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to change the status of these stores.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
foreach ( (array) $ids as $store_id ) {
$store = new Store( absint( $store_id ) );
if ( ! $store->exists() ) {
@@ -923,6 +947,14 @@
$id = absint( $request->get_param( 'id' ) );
$data = (array) $request->get_json_params();
+ if ( ! StoreUtil::current_user_can_manage_store( $id ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to update this store.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
$store = new Store( $id );
if ( ! $store->exists() ) {
return;
--- a/dc-woocommerce-multi-vendor/classes/RestAPI/Controllers/Transactions.php
+++ b/dc-woocommerce-multi-vendor/classes/RestAPI/Controllers/Transactions.php
@@ -8,6 +8,7 @@
namespace MultiVendorXRestAPIControllers;
use MultiVendorXStoreStore;
+use MultiVendorXStoreStoreUtil;
use MultiVendorXTransactionTransaction;
use MultiVendorXUtill;
@@ -122,6 +123,14 @@
$sec_fetch_site = $request->get_header( 'sec_fetch_site' );
$referer = $request->get_header( 'referer' );
+ if ( ! StoreUtil::current_user_can_manage_store( $store_id ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to view this store's transactions.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
$args = array_filter(
array(
'store_id' => $store_id ? $store_id : null,
@@ -248,6 +257,15 @@
)
);
}
+
+ if ( ! StoreUtil::current_user_can_manage_store( $store_id ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to view this store's balance.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
$last_transaction = Transaction::get_balances_for_store( $store_id );
$balance = $last_transaction['balance'];
@@ -307,13 +325,24 @@
if ( ! $store->exists() ) {
return;
}
+
+ if ( ! StoreUtil::current_user_can_manage_store( $store_id ) ) {
+ return new WP_Error(
+ 'rest_forbidden',
+ __( 'You are not allowed to manage this store's transactions.', 'multivendorx' ),
+ array( 'status' => 403 )
+ );
+ }
+
$threshold_amount = MultiVendorX()->setting->get_setting( 'payout_threshold_amount', 0 );
+ $transaction = Transaction::get_balances_for_store( $store_id );
+ $balance = $transaction['balance'];
if ( $disbursement ) {
$method = $request->get_param( 'method' );
$note = $request->get_param( 'note' );
- if ( $threshold_amount < $amount ) {
+ if ( $threshold_amount < $amount && $balance >= $amount ) {
MultiVendorX()->payments->processor->process_payment( $store_id, $amount, null, $method, $note, $disbursement );
return rest_ensure_response(
array(
@@ -325,7 +354,7 @@
}
if ( $withdraw ) {
- if ( 'approve' === $action && $threshold_amount < $amount ) {
+ if ( 'approve' === $action && $threshold_amount < $amount && $balance >= $amount ) {
MultiVendorX()->payments->processor->process_payment( $store_id, $amount, null, null, null, true );
MultiVendorX()->notifications->send_notification_helper(
'withdrawal_released',
--- a/dc-woocommerce-multi-vendor/classes/RestAPI/Rest.php
+++ b/dc-woocommerce-multi-vendor/classes/RestAPI/Rest.php
@@ -344,17 +344,26 @@
*/
public function grant_woocommerce_rest_permission( $permission, $context, $object_id, $post_type ) {
$request_method = $_SERVER['REQUEST_METHOD'] ?? '';
- $allowed_post_types = array(
+
+ $public_post_types = array(
'product',
- 'shop_order',
'shop_coupon',
'product_cat',
+ );
+
+ if ( $request_method === 'GET' && in_array( $post_type, $public_post_types, true ) ) {
+ return true;
+ }
+
+ $private_post_types = array(
+ 'shop_order',
'user',
+ 'payment_gateways',
'bookable_resource',
'wc_appointment',
);
- if ( $request_method === 'GET' && in_array( $post_type, $allowed_post_types, true ) ) {
+ if ( is_user_logged_in() && $request_method === 'GET' && in_array( $post_type, $private_post_types, true ) ) {
return true;
}
@@ -366,17 +375,7 @@
// Get all users for that store.
$users = StoreUtil::get_store_users( $active_store );
- // 'user' (WC_REST_Customers_Controller) and 'payment_gateways' are
- // deliberately NOT in $allowed_post_types above - that array is also
- // used for the anonymous-GET branch a few lines up, and neither of
- // these should ever be readable by a logged-out request (customer
- // PII / marketplace payment config). Only an authenticated member of
- // the active store gets them, for the Store Dashboard "Add Order"
- // screen (`addOrder.tsx`), which needs a customer picker and the
- // marketplace's enabled payment methods.
- $authenticated_only_post_types = array_merge( $allowed_post_types, array( 'user', 'payment_gateways' ) );
-
- if ( is_array( $users ) && ! empty( $users['users'] ) && in_array( $user_id, $users['users'], true ) && in_array( $post_type, $authenticated_only_post_types, true ) ) {
+ if ( is_array( $users ) && ! empty( $users['users'] ) && in_array( $user_id, $users['users'], true ) ) {
return true;
}
--- a/dc-woocommerce-multi-vendor/classes/Store/StoreUtil.php
+++ b/dc-woocommerce-multi-vendor/classes/Store/StoreUtil.php
@@ -497,6 +497,42 @@
return $primary_owner;
}
+
+ /**
+ * Whether the current user may read/manage a specific store's data.
+ *
+ * True for site administrators, or for a user who is the store's primary
+ * owner or a listed staff member. Used to scope REST access to a single
+ * store's records rather than trusting a bare `edit_stores`/`manage_options`
+ * capability check, since `edit_stores` is also granted to the `store_owner`
+ * role itself.
+ *
+ * @param int $store_id Store ID.
+ * @return bool
+ */
+ public static function current_user_can_manage_store( $store_id ) {
+ if ( current_user_can( 'manage_options' ) ) {
+ return true;
+ }
+
+ $store_id = (int) $store_id;
+ if ( ! $store_id ) {
+ return false;
+ }
+
+ $user_id = MultiVendorX()->current_user_id;
+ if ( ! $user_id ) {
+ return false;
+ }
+
+ if ( (int) self::get_primary_owner( $store_id ) === $user_id ) {
+ return true;
+ }
+
+ $store_users = self::get_store_users( $store_id );
+ return in_array( $user_id, (array) $store_users['users'], true );
+ }
+
/**
* Set primary owner for a store.
*
--- a/dc-woocommerce-multi-vendor/config.php
+++ b/dc-woocommerce-multi-vendor/config.php
@@ -9,7 +9,7 @@
define( 'MULTIVENDORX_PLUGIN_TEXTDOMAIN', 'multivendorx' );
-define( 'MULTIVENDORX_PLUGIN_VERSION', '5.0.10' );
+define( 'MULTIVENDORX_PLUGIN_VERSION', '5.0.11' );
define( 'MULTIVENDORX_PRO_SHOP_URL', 'https://multivendorx.com/pricing/?utm_source=wpadmin&utm_medium=pluginsettings&utm_campaign=multivendorx' );
--- a/dc-woocommerce-multi-vendor/dc_product_vendor.php
+++ b/dc-woocommerce-multi-vendor/dc_product_vendor.php
@@ -4,10 +4,10 @@
* Plugin URI: https://multivendorx.com/?utm_source=wpadmin&utm_medium=pluginsettings&utm_campaign=multivendorx
* Description: An AI-powered WooCommerce multivendor marketplace solution to build, manage, and scale your platform.
* Author: MultiVendorX
- * Version: 5.0.10
+ * Version: 5.0.11
* Author URI: https://multivendorx.com/?utm_source=wpadmin&utm_medium=pluginsettings&utm_campaign=multivendorx
* Requires at least: 6.3
- * Tested up to: 7.0.1
+ * Tested up to: 7.0.2
* WC requires at least: 8.2.0
* WC tested up to: 10.9.4
*
--- a/dc-woocommerce-multi-vendor/modules/Elementor/Admin.php
+++ b/dc-woocommerce-multi-vendor/modules/Elementor/Admin.php
@@ -17,6 +17,14 @@
class Admin {
/**
+ * Resolved Elementor template ID for the current request, cached to
+ * avoid repeating the lookup query across the several hooks below.
+ *
+ * @var int|false|null
+ */
+ private $elementor_template_id = null;
+
+ /**
* Constructor.
*/
public function __construct() {
@@ -25,6 +33,10 @@
add_filter( 'multivendorx_store_elementor_template', array( $this, 'elementor_template_filter' ), 10 );
// Add content in Elementor template.
add_action( 'save_post_elementor_library', array( $this, 'default_store_template' ), 10, 3 );
+ // Make sure the store template is included in Elementor's frontend style render pass, however it gets triggered.
+ add_action( 'elementor/frontend/before_enqueue_styles', array( $this, 'register_store_template_for_render' ) );
+ // Trigger Elementor's own frontend style pipeline on the store page, since Elementor doesn't self-attach it there.
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_atomic_widgets_styles' ) );
}
/**
@@ -67,11 +79,72 @@
}
/**
+ * Register the store's Elementor template with Elementor's post/render
+ * pipeline so its Atomic Elements styles are generated in whichever
+ * frontend style render pass actually runs.
+ *
+ * Elementor's `Frontend::enqueue_styles()` only runs its body once per
+ * request (guarded by an internal `static` flag) and only collects
+ * Atomic Elements styles for post IDs that fired `elementor/post/render`
+ * *before* that single pass executes. `elementor-canvas.php` renders the
+ * store template via `get_builder_content()`, which never fires that
+ * action, so hooking here - the first action `enqueue_styles()` fires,
+ * before its render pass - guarantees the store template's ID is
+ * included regardless of whether Elementor's own automatic hook (e.g.
+ * for a real "store" page that happens to be singular) or
+ * {@see self::enqueue_atomic_widgets_styles()} below is what actually
+ * triggers that single pass.
+ *
+ * @return void
+ */
+ public function register_store_template_for_render() {
+ if ( ! get_query_var( MultiVendorX()->store->rewrites->custom_store_url ) ) {
+ return;
+ }
+
+ $elementor_template_id = $this->get_elementor_template();
+
+ if ( $elementor_template_id ) {
+ do_action( 'elementor/post/render', $elementor_template_id );
+ }
+ }
+
+ /**
+ * Trigger Elementor's own frontend style pipeline on the store page.
+ *
+ * Elementor only hooks `Frontend::enqueue_styles()` onto
+ * `wp_enqueue_scripts` for `is_singular()` requests whose queried post is
+ * itself built with Elementor - never for the store page's virtual query
+ * (`Rewrites::make_endpoint_virtual_page()`). Without this, nothing ever
+ * calls Elementor's style pipeline at all on the store page, so we call
+ * its public `enqueue_styles()` method ourselves rather than manually
+ * enqueuing a CSS file. Registration in {@see self::register_store_template_for_render()}
+ * ensures the store template's own styles are included in this pass.
+ *
+ * @return void
+ */
+ public function enqueue_atomic_widgets_styles() {
+ if ( ! class_exists( 'ElementorPlugin' ) || ! did_action( 'elementor/loaded' ) ) {
+ return;
+ }
+
+ if ( ! get_query_var( MultiVendorX()->store->rewrites->custom_store_url ) || ! $this->get_elementor_template() ) {
+ return;
+ }
+
+ ElementorPlugin::$instance->frontend->enqueue_styles();
+ }
+
+ /**
* Get active Elementor template for store.
*
* @return int|false Template ID or false if not found.
*/
private function get_elementor_template() {
+ if ( null !== $this->elementor_template_id ) {
+ return $this->elementor_template_id;
+ }
+
if ( ! did_action( 'elementor/loaded' ) ) {
return false;
}
@@ -91,7 +164,10 @@
);
$templates = get_posts( $args );
- return ! empty( $templates ) ? $templates[0]->ID : false;
+
+ $this->elementor_template_id = ! empty( $templates ) ? $templates[0]->ID : false;
+
+ return $this->elementor_template_id;
}
/**
--- a/dc-woocommerce-multi-vendor/vendor/composer/installed.php
+++ b/dc-woocommerce-multi-vendor/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'multivendorx/multivendorx',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '70fe20a15b3d7752a5e0b4f6383b2b43ce3efcdf',
+ 'reference' => 'a84b9c36f818dc068b3b464e546114fa571378b2',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'multivendorx/multivendorx' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '70fe20a15b3d7752a5e0b4f6383b2b43ce3efcdf',
+ 'reference' => 'a84b9c36f818dc068b3b464e546114fa571378b2',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),