Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/surecart/app/src/Concerns/StripsPrivateCatalogFields.php
+++ b/surecart/app/src/Concerns/StripsPrivateCatalogFields.php
@@ -3,11 +3,25 @@
namespace SureCartConcerns;
/**
- * Strips private catalog data from view/embed REST responses in places
- * the item schema can't reach — expanded sub-objects.
+ * Strips private catalog data from anonymous-facing serializations — view/embed
+ * REST responses in places the item schema can't reach (expanded sub-objects)
+ * and catalog data serialized into public page HTML (see PublicCatalogData).
*/
trait StripsPrivateCatalogFields {
/**
+ * Private field keys excluded from stripping, keyed by catalog object type.
+ *
+ * Empty by default so REST responses strip everything. The public HTML
+ * serializer overrides this to keep the few fields the storefront renders
+ * from — see SureCartSupportPublicCatalogData for the list and reasons.
+ *
+ * @return array
+ */
+ protected function preservedCatalogFields() {
+ return array();
+ }
+
+ /**
* Strip the given private fields from a catalog response array.
*
* @param array $data Response data.
@@ -17,6 +31,11 @@
* @return array
*/
private function stripPrivateFields( $data, $fields, $type ) {
+ $preserved = $this->preservedCatalogFields()[ $type ] ?? array();
+ if ( ! empty( $preserved ) ) {
+ $fields = array_diff( $fields, $preserved );
+ }
+
/**
* Filters the private field keys stripped from view/embed catalog
* REST responses.
@@ -27,7 +46,7 @@
* metadata, offer internals, customer PII) to anonymous callers.
*
* @param array $fields Field keys stripped from the response.
- * @param string $type Catalog object type (product, variant, price, review, product_collection).
+ * @param string $type Catalog object type (product, variant, variant_option, price, review, product_collection, bundle_item).
* @param array $data The response data being stripped.
*/
$fields = apply_filters( 'surecart/rest/private_catalog_fields', $fields, $type, $data );
@@ -89,6 +108,10 @@
$product['variants']['data'] = array_map( [ $this, 'stripPrivateVariantFields' ], $product['variants']['data'] );
}
+ if ( ! empty( $product['variant_options']['data'] ) && is_array( $product['variant_options']['data'] ) ) {
+ $product['variant_options']['data'] = array_map( [ $this, 'stripPrivateVariantOptionFields' ], $product['variant_options']['data'] );
+ }
+
if ( ! empty( $product['prices']['data'] ) && is_array( $product['prices']['data'] ) ) {
$product['prices']['data'] = array_map( [ $this, 'stripPrivatePriceFields' ], $product['prices']['data'] );
}
@@ -101,6 +124,10 @@
$product['product_collections']['data'] = array_map( [ $this, 'stripPrivateCollectionFields' ], $product['product_collections']['data'] );
}
+ if ( ! empty( $product['bundle_items']['data'] ) && is_array( $product['bundle_items']['data'] ) ) {
+ $product['bundle_items']['data'] = array_map( [ $this, 'stripPrivateBundleItemFields' ], $product['bundle_items']['data'] );
+ }
+
// accessor-derived copies (Model::toArray appends every get*Attribute) leak the same fields.
foreach ( [ 'active_prices', 'active_ad_hoc_prices' ] as $key ) {
if ( ! empty( $product[ $key ] ) && is_array( $product[ $key ] ) ) {
@@ -157,6 +184,71 @@
}
/**
+ * Strip private fields from a variant option array.
+ *
+ * Variant options ride along on products and bundle items
+ * (variant_options / component_variant_options) and carry metadata.
+ *
+ * @param array|mixed $option Variant option response data. Non-arrays pass through untouched.
+ *
+ * @return array|mixed
+ */
+ protected function stripPrivateVariantOptionFields( $option ) {
+ if ( ! is_array( $option ) ) {
+ return $option;
+ }
+
+ return $this->stripPrivateFields(
+ $option,
+ [
+ 'metadata',
+ ],
+ 'variant_option'
+ );
+ }
+
+ /**
+ * Strip private fields from a bundle item array.
+ *
+ * A bundle item expands the component product (and its variants) the
+ * bundle checkout renders — the nested product carries the same private
+ * fields as a top-level one, so it gets the same treatment.
+ *
+ * @param array|mixed $item Bundle item response data. Non-arrays pass through untouched.
+ *
+ * @return array|mixed
+ */
+ protected function stripPrivateBundleItemFields( $item ) {
+ if ( ! is_array( $item ) ) {
+ return $item;
+ }
+
+ $item = $this->stripPrivateFields(
+ $item,
+ [
+ 'metadata',
+ ],
+ 'bundle_item'
+ );
+
+ foreach ( [ 'component_product', 'bundle_product' ] as $key ) {
+ if ( ! empty( $item[ $key ] ) && is_array( $item[ $key ] ) ) {
+ $item[ $key ] = $this->stripPrivateProductFields( $item[ $key ] );
+ }
+ }
+
+ if ( ! empty( $item['component_variants']['data'] ) && is_array( $item['component_variants']['data'] ) ) {
+ $item['component_variants']['data'] = array_map( [ $this, 'stripPrivateVariantFields' ], $item['component_variants']['data'] );
+ }
+
+ if ( ! empty( $item['component_variant_options']['data'] ) && is_array( $item['component_variant_options']['data'] ) ) {
+ $item['component_variant_options']['data'] = array_map( [ $this, 'stripPrivateVariantOptionFields' ], $item['component_variant_options']['data'] );
+ }
+
+ return $item;
+ }
+
+ /**
* Strip private fields from a price array.
*
* Keeps scratch_amount — the storefront renders it as the compare-at price.
@@ -170,7 +262,7 @@
return $price;
}
- return $this->stripPrivateFields(
+ $price = $this->stripPrivateFields(
$price,
[
'metadata',
@@ -179,6 +271,13 @@
],
'price'
);
+
+ // a price can expand its product — it carries the same private fields.
+ if ( ! empty( $price['product'] ) && is_array( $price['product'] ) ) {
+ $price['product'] = $this->stripPrivateProductFields( $price['product'] );
+ }
+
+ return $price;
}
/**
--- a/surecart/app/src/Controllers/Rest/CustomerController.php
+++ b/surecart/app/src/Controllers/Rest/CustomerController.php
@@ -106,25 +106,52 @@
/**
* Edit model.
*
+ * Platform first — the linked WordPress user is only synced from the
+ * response the platform actually accepted, never from raw request input.
+ *
* @param WP_REST_Request $request Rest Request.
*
- * @return WP_REST_Response|WP_Error
+ * @return SureCartModelsCustomer|WP_Error
*/
public function edit( WP_REST_Request $request ) {
- $wp_user = User::findByCustomerId( $request['id'] );
+ $customer = parent::edit( $request );
+
+ if ( is_wp_error( $customer ) || empty( $customer ) ) {
+ return $customer;
+ }
+
+ $this->syncWPUser( $customer );
+
+ return $customer;
+ }
+
+ /**
+ * Sync the linked WordPress user's profile from an updated customer.
+ *
+ * Best-effort — the platform write has already succeeded, so a failed
+ * local update must not fail the request. Delegates the actual field
+ * sync (and its "never sync email" rule) to UsersService so the webhook
+ * and REST paths can't drift apart.
+ *
+ * @param SureCartModelsCustomer $customer The updated customer returned by the platform.
+ *
+ * @return void
+ */
+ protected function syncWPUser( $customer ) {
+ $wp_user = User::findByCustomerId( $customer->id );
+ if ( ! $wp_user || empty( $wp_user->ID ) ) {
+ return;
+ }
- if ( ! empty( $wp_user->ID ) ) {
- wp_update_user(
- [
- 'ID' => $wp_user->ID,
- 'user_email' => ! empty( $request['email'] ) ? $request['email'] : $wp_user->user_email,
- 'first_name' => ! empty( $request['first_name'] ) ? $request['first_name'] : $wp_user->first_name,
- 'last_name' => ! empty( $request['last_name'] ) ? $request['last_name'] : $wp_user->last_name,
- 'phone' => ! empty( $request['phone'] ) ? $request['phone'] : $wp_user->phone,
- ]
- );
+ // dispatch through the edit_sc_customer meta cap so this stays in sync with the
+ // user_has_cap filtering the rest of the codebase relies on for ownership checks.
+ if ( ! current_user_can( 'edit_sc_customer', $customer->id, [] ) ) {
+ return;
}
- return parent::edit( $request );
+ $users_service = SureCart::resolve( 'surecart.users' );
+ if ( $users_service ) {
+ $users_service->applyCustomerToWPUser( $wp_user, $customer );
+ }
}
}
--- a/surecart/app/src/Controllers/Web/UpsellPageController.php
+++ b/surecart/app/src/Controllers/Web/UpsellPageController.php
@@ -2,6 +2,8 @@
namespace SureCartControllersWeb;
+use SureCartSupportPublicCatalogData;
+
/**
* Handles Upsell Page requests for frontend.
*/
@@ -92,16 +94,22 @@
// add the filters.
$this->filters();
+ // the upsell expands its price — strip catalog data before it hits public state.
+ $upsell = json_decode( wp_json_encode( $this->model ), true );
+ if ( ! empty( $upsell['price'] ) && is_array( $upsell['price'] ) ) {
+ $upsell['price'] = PublicCatalogData::price( $upsell['price'] );
+ }
+
// Set initial state.
sc_initial_state(
[
'product' => [
// we need to force the selected price.
- $this->product->id => $this->product->getInitialPageState( [ 'selectedPrice' => $this->model->price->toArray() ] ),
+ $this->product->id => $this->product->getInitialPageState( [ 'selectedPrice' => PublicCatalogData::price( $this->model->price ) ] ),
],
'upsell' => [
- 'product' => $this->product,
- 'upsell' => $this->model,
+ 'product' => PublicCatalogData::product( $this->product ),
+ 'upsell' => $upsell,
'form_id' => (int) $request->query( 'sc_form_id' ) ?? null,
'checkout_id' => esc_attr( $request->query( 'sc_checkout_id' ) ?? null ),
'text' => $this->getCheckoutText( (int) $request->query( 'sc_form_id' ) ?? '' ),
--- a/surecart/app/src/Integrations/Bricks/Elements/Media.php
+++ b/surecart/app/src/Integrations/Bricks/Elements/Media.php
@@ -150,6 +150,7 @@
'type' => 'number',
'default' => 5,
'min' => 2,
+ 'max' => 12,
'placeholder' => 5,
'required' => [
[ 'desktop_gallery', '=', 'slider' ],
@@ -177,7 +178,7 @@
public function render() {
$product = sc_get_product();
$settings = $this->settings;
- $thumbnails_per_page = ! empty( $settings['thumbnails_per_page'] ) ? (int) $settings['thumbnails_per_page'] : 5;
+ $thumbnails_per_page = max( 2, min( 12, ! empty( $settings['thumbnails_per_page'] ) ? (int) $settings['thumbnails_per_page'] : 5 ) );
$desktop_gallery = ! empty( $settings['desktop_gallery'] ) ? $settings['desktop_gallery'] : 'slider';
if ( $this->is_admin_editor() ) {
@@ -233,7 +234,7 @@
'width' => esc_html( $this->settings['max_image_width'] ?? null ),
'thumbnails_per_page' => $thumbnails_per_page,
'desktop_gallery' => 'gallery' === $desktop_gallery,
- 'show_thumbs' => (bool) ! empty( $this->settings['show_thumbs'] ),
+ 'show_thumbnails' => (bool) ! empty( $this->settings['show_thumbs'] ),
]
);
}
--- a/surecart/app/src/Integrations/Elementor/Widgets/Media.php
+++ b/surecart/app/src/Integrations/Elementor/Widgets/Media.php
@@ -232,6 +232,8 @@
[
'label' => esc_html__( 'Thumbnails per Page', 'surecart' ),
'type' => ElementorControls_Manager::NUMBER,
+ 'min' => 2,
+ 'max' => 12,
'default' => 5,
'description' => esc_html__( 'Set the number of thumbnails to show per page.', 'surecart' ),
'condition' => [
@@ -292,13 +294,13 @@
$height = ! $auto_height ? ( ! empty( $settings['slider_height']['size'] ) ? $settings['slider_height']['size'] . $settings['slider_height']['unit'] : '' ) : '';
$attributes = array(
- 'thumbnails_per_page' => $settings['thumbnails_per_page'],
+ 'thumbnails_per_page' => $this->get_thumbnails_per_page( $settings ),
'auto_height' => $auto_height,
'height' => $height,
'width' => ! empty( $settings['slider_max_image_width']['size'] ) ? $settings['slider_max_image_width']['size'] . $settings['slider_max_image_width']['unit'] : '',
'lightbox' => 'yes' === $settings['lightbox'],
'desktop_gallery' => 'gallery' === $settings['desktop_gallery'],
- 'show_thumbs' => 'yes' === $settings['show_thumbs'],
+ 'show_thumbnails' => 'yes' === $settings['show_thumbs'],
);
?>
@@ -309,6 +311,18 @@
}
/**
+ * Get the thumbnails per page setting, clamped to the 2-12 range the thumbnail styles support.
+ *
+ * Values saved before the control had a minimum can be out of range (e.g. 1).
+ *
+ * @param array $settings Widget settings.
+ * @return int
+ */
+ protected function get_thumbnails_per_page( $settings ) {
+ return max( 2, min( 12, ! empty( $settings['thumbnails_per_page'] ) ? (int) $settings['thumbnails_per_page'] : 5 ) );
+ }
+
+ /**
* Render content specifically for the editor with dynamic product data.
*
* @param array $settings Widget settings.
@@ -398,7 +412,7 @@
* @return void
*/
protected function render_slider_view( $images, $settings ) {
- $thumbnails_per_page = $settings['thumbnails_per_page'];
+ $thumbnails_per_page = $this->get_thumbnails_per_page( $settings );
$show_thumbs = 'yes' === $settings['show_thumbs'];
?>
<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
--- a/surecart/app/src/Models/Product.php
+++ b/surecart/app/src/Models/Product.php
@@ -10,6 +10,7 @@
use SureCartSupportContractsGalleryItem;
use SureCartSupportContractsPageModel;
use SureCartSupportCurrency;
+use SureCartSupportPublicCatalogData;
use SureCartSupportTimeDate;
/**
@@ -1198,6 +1199,9 @@
/**
* Get the product page initial state
*
+ * This is serialized into public page HTML, so catalog data is stripped
+ * of private fields (see PublicCatalogData).
+ *
* @param array $args Array of arguments.
*
* @return array
@@ -1210,13 +1214,13 @@
[
'formId' => $form->ID,
'mode' => SureCartModelsForm::getMode( $form->ID ),
- 'product' => $this,
- 'prices' => $this->active_prices,
- 'selectedPrice' => ( $this->active_prices ?? [] )[0] ?? null,
+ 'product' => PublicCatalogData::product( $this ),
+ 'prices' => array_map( [ PublicCatalogData::class, 'price' ], $this->active_prices ?? [] ),
+ 'selectedPrice' => PublicCatalogData::price( ( $this->active_prices ?? [] )[0] ?? null ),
'checkoutUrl' => SureCart::pages()->url( 'checkout' ),
- 'variant_options' => $this->variant_options->data ?? [],
- 'variants' => $this->variants->data ?? [],
- 'selectedVariant' => $this->initial_variant ?? null,
+ 'variant_options' => array_map( [ PublicCatalogData::class, 'variantOption' ], $this->variant_options->data ?? [] ),
+ 'variants' => array_map( [ PublicCatalogData::class, 'variant' ], $this->variants->data ?? [] ),
+ 'selectedVariant' => PublicCatalogData::variant( $this->initial_variant ?? null ),
'isProductPage' => ! empty( get_query_var( 'surecart_current_product' )->id ),
]
);
--- a/surecart/app/src/Models/User.php
+++ b/surecart/app/src/Models/User.php
@@ -178,8 +178,10 @@
/**
* Set the customer id in the user meta.
*
- * @param string $id Customer id.
- * @return $this|bool
+ * @param string $id Customer id.
+ * @param string $mode Customer mode (live or test).
+ * @param boolean $force Overwrite an existing link.
+ * @return $this|WP_Error
*/
protected function setCustomerId( $id, $mode = 'live', $force = false ) {
$meta = (array) get_user_meta( $this->user->ID, $this->customer_id_key, true );
@@ -193,6 +195,14 @@
return new WP_Error( 'already_linked', __( 'This user is already linked to a customer.', 'surecart' ) );
}
}
+
+ // prevent a second account binding a customer id another user already holds (account takeover vector).
+ if ( ! $force ) {
+ $holder = ( new static() )->findByCustomerId( $id );
+ if ( $holder && (int) $holder->ID !== (int) $this->user->ID ) {
+ return new WP_Error( 'customer_id_in_use', __( 'This customer is already linked to another user.', 'surecart' ) );
+ }
+ }
}
// update id.
@@ -503,32 +513,46 @@
/**
* Find the user by customer id.
*
+ * Fails closed when more than one user holds the id — resolving an
+ * ambiguous id to an arbitrary user is an account takeover vector.
+ *
* @param string $id Customer id string.
- * @return $this
+ * @return $this|false This object on success, false if not found or ambiguous.
*/
protected function findByCustomerId( $id ) {
if ( ! is_string( $id ) || empty( $id ) ) {
return false;
}
+ // anchor on the serialized value delimiters (s:<len>:"<value>";) so 'cus_ABC' cannot match 'cus_ABCDEF'.
$users = new WP_User_Query(
[
+ 'number' => 2, // two rows is enough to detect ambiguity.
+ 'fields' => 'ID',
'meta_query' => [
[
'key' => $this->customer_id_key,
- 'value' => $id,
+ 'value' => ':"' . $id . '";',
'compare' => 'LIKE',
],
],
]
);
- if ( empty( $users->results ) ) {
+ // verify in PHP — the LIKE can also match a serialized mode key (e.g. an id literally named 'test').
+ $verified = [];
+ foreach ( (array) $users->get_results() as $user_id ) {
+ if ( ( new static() )->find( $user_id )->hasCustomerId( $id ) ) {
+ $verified[] = (int) $user_id;
+ }
+ }
+
+ if ( 1 !== count( $verified ) ) {
return false;
}
- $this->user = $users->results[0];
- return $this;
+ $this->user = get_user_by( 'id', $verified[0] );
+ return $this->user ? $this : false;
}
/**
--- a/surecart/app/src/Permissions/Models/ModelPermissionsController.php
+++ b/surecart/app/src/Permissions/Models/ModelPermissionsController.php
@@ -73,18 +73,26 @@
* Is ths user listing their own customer ids.
*
* @param SureCartModelsUser $user User model.
- * @param array $customer_ids Array of customer ids.
+ * @param mixed $customer_ids Requested customer ids — only a sequential list of id strings authorizes.
* @return boolean
*/
protected function isListingOwnCustomerIds( $user, $customer_ids ) {
// must have list.
- if ( empty( $customer_ids ) ) {
+ if ( empty( $customer_ids ) || ! is_array( $customer_ids ) ) {
return false;
}
+ // only authorize a sequential list — the platform ignores (rather than filters on)
+ // associative customer_ids, so this guard and the platform must agree on the encoding.
+ if ( array_keys( $customer_ids ) !== range( 0, count( $customer_ids ) - 1 ) ) {
+ return false;
+ }
+
+ $owned = (array) $user->customerIds();
+
// check each one.
foreach ( $customer_ids as $id ) {
- if ( ! $id || ! in_array( $id, (array) $user->customerIds() ) ) {
+ if ( ! is_string( $id ) || '' === $id || ! in_array( $id, $owned, true ) ) {
return false; // this id does not belong to the user.
}
}
--- a/surecart/app/src/Rest/CheckoutRestServiceProvider.php
+++ b/surecart/app/src/Rest/CheckoutRestServiceProvider.php
@@ -6,6 +6,7 @@
use SureCartControllersRestCheckoutsController;
use SureCartFormFormValidationService;
use SureCartModelsUser;
+use SureCartSupportPublicCatalogData;
/**
* Service provider for Price Rest Requests
@@ -33,6 +34,14 @@
protected $converts_currency = true;
/**
+ * Filter each index item by schema context, so the edit-only customer
+ * fields are not emitted on view-context lists.
+ *
+ * @var boolean
+ */
+ protected $filters_list_items = true;
+
+ /**
* Methods allowed for the model.
*
* @var array
@@ -274,7 +283,7 @@
}
}
- return rest_filter_response_by_context( $data, $schema, 'view' );
+ return rest_filter_response_by_context( PublicCatalogData::lineItems( $data ), $schema, 'view' );
}
@@ -295,6 +304,11 @@
* @return true|WP_Error True if the request has access to create items, WP_Error object otherwise.
*/
public function get_items_permissions_check( $request ) {
+ $check = $this->forbidEditContextWithout( $request, 'edit_sc_checkouts' );
+ if ( is_wp_error( $check ) ) {
+ return $check;
+ }
+
return current_user_can( 'read_sc_checkouts', $request->get_params() );
}
--- a/surecart/app/src/Support/PublicCatalogData.php
+++ b/surecart/app/src/Support/PublicCatalogData.php
@@ -0,0 +1,148 @@
+<?php
+
+namespace SureCartSupport;
+
+use SureCartConcernsStripsPrivateCatalogFields;
+
+/**
+ * Strips private catalog fields from anything an anonymous visitor can read.
+ *
+ * Storefront and checkout pages serialize catalog models into component data
+ * scripts and the `#sc-store-data` initial state, and the guest checkout routes
+ * return products expanded onto line items. This runs the same strip as the
+ * anonymous catalog REST routes on all of them, so the paths cannot drift apart.
+ *
+ * Nothing enforces this at the output boundary yet: a new serialization of a
+ * product, price or variant into page HTML is unprotected until it is routed
+ * through here.
+ *
+ * @see SureCartConcernsStripsPrivateCatalogFields Field lists and the
+ * `surecart/rest/private_catalog_fields` filter.
+ */
+class PublicCatalogData {
+ use StripsPrivateCatalogFields;
+
+ /**
+ * Fields the storefront renders from, kept at this boundary only.
+ *
+ * - available_stock: sold-out gates, in-stock variant selection and
+ * quantity caps (sc-product-quantity, sc-line-items, the price/variant
+ * selectors and the bundle component picker).
+ * - purchase_limit: quantity caps (getMaxStockQuantity).
+ * - archived: render gates (sc-price-choice, product store getters).
+ *
+ * The REST providers keep stripping these — the storefront renders stock
+ * state server-side, the anonymous REST catalog does not need to.
+ *
+ * @return array
+ */
+ protected function preservedCatalogFields() {
+ return array(
+ 'product' => array( 'available_stock', 'purchase_limit', 'archived' ),
+ 'variant' => array( 'available_stock' ),
+ );
+ }
+
+ /**
+ * Get product data safe to serialize into public page HTML.
+ *
+ * @param SureCartModelsProduct|array|object|null $product The product model or its array/object form.
+ *
+ * @return array|mixed The stripped product array. Non-object/array input passes through untouched.
+ */
+ public static function product( $product ) {
+ return ( new self() )->stripPrivateProductFields( self::toDataArray( $product ) );
+ }
+
+ /**
+ * Get price data safe to serialize into public page HTML.
+ *
+ * Also strips an expanded product on the price.
+ *
+ * @param SureCartModelsPrice|array|object|null $price The price model or its array/object form.
+ *
+ * @return array|mixed The stripped price array. Non-object/array input passes through untouched.
+ */
+ public static function price( $price ) {
+ return ( new self() )->stripPrivatePriceFields( self::toDataArray( $price ) );
+ }
+
+ /**
+ * Get variant data safe to serialize into public page HTML.
+ *
+ * @param SureCartModelsVariant|array|object|null $variant The variant model or its array/object form.
+ *
+ * @return array|mixed The stripped variant array. Non-object/array input passes through untouched.
+ */
+ public static function variant( $variant ) {
+ return ( new self() )->stripPrivateVariantFields( self::toDataArray( $variant ) );
+ }
+
+ /**
+ * Get variant option data safe to serialize into public page HTML.
+ *
+ * @param SureCartModelsVariantOption|array|object|null $option The variant option model or its array/object form.
+ *
+ * @return array|mixed The stripped variant option array. Non-object/array input passes through untouched.
+ */
+ public static function variantOption( $option ) {
+ return ( new self() )->stripPrivateVariantOptionFields( self::toDataArray( $option ) );
+ }
+
+ /**
+ * Strip catalog data expanded onto a checkout's line items.
+ *
+ * The checkout routes accept anonymous callers by design (guest checkout),
+ * and `expand=price.product` pulls a full product into the response — the
+ * same data the page output strips, reachable without a purchase. Applied
+ * to the view context only, so the owner and the matching customer still
+ * get the full record.
+ *
+ * @param array|mixed $data Checkout response data. Anything else passes through untouched.
+ *
+ * @return array|mixed
+ */
+ public static function lineItems( $data ) {
+ if ( ! is_array( $data ) || empty( $data['line_items']['data'] ) || ! is_array( $data['line_items']['data'] ) ) {
+ return $data;
+ }
+
+ $data['line_items']['data'] = array_map(
+ function ( $item ) {
+ if ( ! is_array( $item ) ) {
+ return $item;
+ }
+
+ // the price strip recurses into its expanded product.
+ if ( ! empty( $item['price'] ) && is_array( $item['price'] ) ) {
+ $item['price'] = self::price( $item['price'] );
+ }
+
+ if ( ! empty( $item['variant'] ) && is_array( $item['variant'] ) ) {
+ $item['variant'] = self::variant( $item['variant'] );
+ }
+
+ return $item;
+ },
+ $data['line_items']['data']
+ );
+
+ return $data;
+ }
+
+ /**
+ * Normalize a model/object to the exact array shape wp_json_encode outputs,
+ * so stripping sees what would have been serialized.
+ *
+ * @param mixed $data The data to normalize.
+ *
+ * @return array|mixed
+ */
+ private static function toDataArray( $data ) {
+ if ( null === $data || is_scalar( $data ) ) {
+ return $data;
+ }
+
+ return json_decode( wp_json_encode( $data ), true );
+ }
+}
--- a/surecart/app/src/WordPress/Users/CustomerLinkService.php
+++ b/surecart/app/src/WordPress/Users/CustomerLinkService.php
@@ -2,6 +2,7 @@
namespace SureCartWordPressUsers;
+use SureCartModelsCustomer;
use SureCartModelsUser;
/**
@@ -36,7 +37,7 @@
/**
* Link the user to the checkout.
*
- * @return SureCartModelsUser|WP_Error
+ * @return SureCartModelsUser|WP_Error|false
*/
public function link() {
// if the customer already linked.
@@ -73,23 +74,66 @@
// next check if email has a user.
$existing = User::getUserBy( 'email', $this->checkout->email );
- // We have a user, link it.
- if ( $existing ) {
- $mode = ! empty( $this->checkout->live_mode ) ? 'live' : 'test';
- // maybe add the customer id for the user if it's not yet set.
- if ( ! $existing->customerId( $mode ) ) {
- $existing->setCustomerId( $this->checkout->customer_id, $mode );
- return $existing;
+ // no user for this email.
+ if ( ! $existing ) {
+ return false;
+ }
+
+ $mode = ! empty( $this->checkout->live_mode ) ? 'live' : 'test';
+
+ // the user already has a customer id for this mode.
+ if ( $existing->customerId( $mode ) ) {
+ return false;
+ }
+
+ // the checkout's email and customer are independently attacker-controlled — only link when the customer record's own email matches this user.
+ $customer_email = $this->getCustomerEmail();
+ if ( empty( $customer_email ) ) {
+ error_log( 'SureCart: Could not determine the customer email for checkout ' . $this->checkout->id . ' - refusing to link a user by email.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ return false;
+ }
+ if ( strtolower( $customer_email ) !== strtolower( $existing->user_email ) ) {
+ error_log( 'SureCart: Customer ' . $this->checkout->customer_id . ' email does not match the user matched by checkout ' . $this->checkout->id . ' email - refusing to link.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ return false;
+ }
+
+ // a failed link (e.g. the id is already held by another user) must not report success.
+ $linked = $existing->setCustomerId( $this->checkout->customer_id, $mode );
+ if ( is_wp_error( $linked ) ) {
+ error_log( 'SureCart: Could not link customer ' . $this->checkout->customer_id . ' for checkout ' . $this->checkout->id . ' - ' . $linked->get_error_message() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ return false;
+ }
+
+ return $existing;
+ }
+
+ /**
+ * Get the checkout customer's email, fetching the customer when not expanded.
+ *
+ * @return string|null
+ */
+ protected function getCustomerEmail() {
+ $email = $this->checkout->customer->email ?? null;
+ if ( ! empty( $email ) ) {
+ return $email;
+ }
+
+ // not expanded (or expanded without an email) — fetch by id so the link is justified by platform data, failing closed only as a last resort.
+ $id = $this->checkout->customer_id;
+ if ( is_string( $id ) && ! empty( $id ) ) {
+ $customer = Customer::find( $id );
+ if ( ! is_wp_error( $customer ) && ! empty( $customer->email ) ) {
+ return $customer->email;
}
}
- return false;
+ return null;
}
/**
* Create the user and link it.
*
- * @return SureCartModelsUser|WP_Error
+ * @return SureCartModelsUser|WP_Error|false
*/
protected function linkNewUser() {
global $wpdb;
--- a/surecart/app/src/WordPress/Users/UsersService.php
+++ b/surecart/app/src/WordPress/Users/UsersService.php
@@ -32,28 +32,44 @@
$wp_user = SureCartModelsUser::findByCustomerId( $customer->id );
if ( ! empty( $wp_user->ID ) ) {
- // prevent potential infinite loop of catching a webhook and updating again.
- remove_action( 'profile_update', array( $this, 'syncUserProfile' ), 10 );
-
- // update user.
- // Intentionally NOT syncing user_email from the webhook payload — CVE-2026-7655 (account takeover via lost-password).
- wp_update_user(
- array(
- 'ID' => $wp_user->ID,
- 'first_name' => ! empty( $customer->first_name ) ? $customer->first_name : $wp_user->first_name,
- 'last_name' => ! empty( $customer->last_name ) ? $customer->last_name : $wp_user->last_name,
- 'phone' => ! empty( $customer->phone ) ? $customer->phone : $wp_user->phone,
- )
- );
-
- // re-add profile_update in case it is done in the same request somewhere.
- add_action( 'profile_update', array( $this, 'syncUserProfile' ), 10 );
+ $this->applyCustomerToWPUser( $wp_user, $customer );
}
return $wp_user;
}
/**
+ * Apply a customer's profile fields to its linked WP user.
+ *
+ * Shared by the webhook-driven syncCustomerProfile() and the REST-driven
+ * customer edit flow so the "never sync email" rule lives in one place.
+ * Intentionally NOT syncing user_email — CVE-2026-7655 (account takeover via lost-password).
+ *
+ * @param WP_User $wp_user The linked WP user.
+ * @param object $customer Customer data.
+ *
+ * @return int|WP_Error The updated user ID or a WP_Error.
+ */
+ public function applyCustomerToWPUser( $wp_user, $customer ) {
+ // prevent potential infinite loop of catching a webhook/request and updating again.
+ remove_action( 'profile_update', array( $this, 'syncUserProfile' ), 10 );
+
+ $result = wp_update_user(
+ array(
+ 'ID' => $wp_user->ID,
+ 'first_name' => ! empty( $customer->first_name ) ? $customer->first_name : $wp_user->first_name,
+ 'last_name' => ! empty( $customer->last_name ) ? $customer->last_name : $wp_user->last_name,
+ 'phone' => ! empty( $customer->phone ) ? $customer->phone : $wp_user->phone,
+ )
+ );
+
+ // re-add profile_update in case it is done in the same request somewhere.
+ add_action( 'profile_update', array( $this, 'syncUserProfile' ), 10 );
+
+ return $result;
+ }
+
+ /**
* Fires immediately after an existing user is updated.
*
* @param int $user_id User ID.
--- a/surecart/dist/admin/abandoned-checkouts.asset.php
+++ b/surecart/dist/admin/abandoned-checkouts.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'b8fd59ac205f2c30d6de');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '33d4d02cc18fe7aba92e');
--- a/surecart/dist/admin/affiliation-payouts-groups.asset.php
+++ b/surecart/dist/admin/affiliation-payouts-groups.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '0affb1a2a632081e5c18');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'dd9703b7bf0ed407aea9');
--- a/surecart/dist/admin/affiliation-payouts.asset.php
+++ b/surecart/dist/admin/affiliation-payouts.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'e26496079ccddccaf9a8');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'fbc01f7602e5785f55e6');
--- a/surecart/dist/admin/affiliation-referrals.asset.php
+++ b/surecart/dist/admin/affiliation-referrals.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '1e08c3001a300bf91329');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '145ed3f033e5b482cf01');
--- a/surecart/dist/admin/affiliation-requests.asset.php
+++ b/surecart/dist/admin/affiliation-requests.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '99493f7fbbfc5dbeaadc');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '44978869b5379ab8c95a');
--- a/surecart/dist/admin/affiliations.asset.php
+++ b/surecart/dist/admin/affiliations.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'a49a3fca0bca22f9bc5b');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '555c98c63b7521fbd42f');
--- a/surecart/dist/admin/auto-fees.asset.php
+++ b/surecart/dist/admin/auto-fees.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '94a76d700e3b787f4b98');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '5d3885020f7de4e58725');
--- a/surecart/dist/admin/bumps.asset.php
+++ b/surecart/dist/admin/bumps.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'a526e230d7d584e550ea');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'baff465f0e7578d2a9bf');
--- a/surecart/dist/admin/bundles.asset.php
+++ b/surecart/dist/admin/bundles.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => 'e4edbc3588350b75b2ae');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => '572719bf8645c623b41b');
--- a/surecart/dist/admin/checkouts.asset.php
+++ b/surecart/dist/admin/checkouts.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'b1ed6108e1330b093884');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '1948cc1ad220fab82a2d');
--- a/surecart/dist/admin/coupons.asset.php
+++ b/surecart/dist/admin/coupons.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '1fbaa3c0e45623150427');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'e4306630be9d1629bf3f');
--- a/surecart/dist/admin/customers.asset.php
+++ b/surecart/dist/admin/customers.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '52fd5bb74391cf67af15');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '13b92f405b377cae7955');
--- a/surecart/dist/admin/dashboard.asset.php
+++ b/surecart/dist/admin/dashboard.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-url'), 'version' => '483b9455ae635562b281');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-url'), 'version' => 'f44f59f4e0599ffd7e5a');
--- a/surecart/dist/admin/invoices.asset.php
+++ b/surecart/dist/admin/invoices.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '965b1dc8bc0ff367dacd');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '55d74e9eea782f60f5c3');
--- a/surecart/dist/admin/licenses.asset.php
+++ b/surecart/dist/admin/licenses.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '1517ba93e4d481c21b2d');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '345c64a4c5acb263cfc8');
--- a/surecart/dist/admin/onboarding.asset.php
+++ b/surecart/dist/admin/onboarding.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '699be8cd72d11c7d9e55');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'c24e7bc53cb88146696d');
--- a/surecart/dist/admin/orders.asset.php
+++ b/surecart/dist/admin/orders.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'bb5cdf3c28fb6568af27');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '449f62853cb80efc678f');
--- a/surecart/dist/admin/product-collections.asset.php
+++ b/surecart/dist/admin/product-collections.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => 'b11cf6abead7ea0fc515');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => 'ad25233ca4bc3310f187');
--- a/surecart/dist/admin/product-groups.asset.php
+++ b/surecart/dist/admin/product-groups.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => 'caecc8f72c4039096154');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => 'b90719f1f72a7c76866d');
--- a/surecart/dist/admin/products.asset.php
+++ b/surecart/dist/admin/products.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => '277c3a7316703c81e430');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => '82e8b8a1067d4ba807ec');
--- a/surecart/dist/admin/reviews.asset.php
+++ b/surecart/dist/admin/reviews.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => '8a6d813bcee693e1bf52');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-url'), 'version' => '82d01210c2fc92d9a141');
--- a/surecart/dist/admin/settings.asset.php
+++ b/surecart/dist/admin/settings.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'e6784d1ef48db61dc8e0');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '6986f158e2ab9f3e76ce');
--- a/surecart/dist/admin/settings/learn.asset.php
+++ b/surecart/dist/admin/settings/learn.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-notices'), 'version' => '90b8679e27068aacb79b');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-notices'), 'version' => 'a19288b17006dfdfbaa7');
--- a/surecart/dist/admin/subscriptions/edit.asset.php
+++ b/surecart/dist/admin/subscriptions/edit.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '036e2c99a390af3ff529');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'b092c313f4017858f9a8');
--- a/surecart/dist/admin/subscriptions/show.asset.php
+++ b/surecart/dist/admin/subscriptions/show.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'a7656f7d642cdf191e2b');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '66af635619a927443acb');
--- a/surecart/dist/admin/upsell-funnels.asset.php
+++ b/surecart/dist/admin/upsell-funnels.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => '906c0f4c3b7e984e2556');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'regenerator-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-notices', 'wp-url'), 'version' => 'afb4dddd38d7cffa2d93');
--- a/surecart/dist/blocks/cart.asset.php
+++ b/surecart/dist/blocks/cart.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'wp-blockEditor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '25be8bde68e2ae368215');
+<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '4cbf920e25f12a615340');
--- a/surecart/dist/blocks/library.asset.php
+++ b/surecart/dist/blocks/library.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-blockEditor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-dom', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => 'e86d213da87d96100b17');
+<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-dom', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '2169731b117c72210eca');
--- a/surecart/dist/blocks/product.asset.php
+++ b/surecart/dist/blocks/product.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'wp-blockEditor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '71edfbb8a1d955b927c8');
+<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => 'b0b843e7bec01ce468c6');
--- a/surecart/dist/blocks/product_collection.asset.php
+++ b/surecart/dist/blocks/product_collection.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'wp-blockEditor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '818f8ef8d9085ca990a6');
+<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '818f8ef8d9085ca990a6');
--- a/surecart/packages/blocks-next/build/blocks/product-list-related/controller.php
+++ b/surecart/packages/blocks-next/build/blocks/product-list-related/controller.php
@@ -12,8 +12,11 @@
);
// Create controller and run query.
-$query = sc_product_list_query( $block );
-$products = $query->products;
+$query = sc_product_list_query( $block );
+
+$products = is_array( $query->products ?? null )
+ ? array_map( [ SureCartSupportPublicCatalogData::class, 'product' ], $query->products )
+ : $query->products;
if ( empty( $products ) ) {
return;
--- a/surecart/packages/blocks-next/build/blocks/product-list/controller.php
+++ b/surecart/packages/blocks-next/build/blocks/product-list/controller.php
@@ -12,8 +12,11 @@
);
// For Analytics.
-$query = sc_product_list_query( $block );
-$products = $query->products;
+$query = sc_product_list_query( $block );
+
+$products = is_array( $query->products ?? null )
+ ? array_map( [ SureCartSupportPublicCatalogData::class, 'product' ], $query->products )
+ : $query->products;
// return the view.
return 'file:./view.php';
--- a/surecart/packages/blocks-next/build/blocks/product-price-choice-template/view.php
+++ b/surecart/packages/blocks-next/build/blocks/product-price-choice-template/view.php
@@ -1,7 +1,7 @@
<div
<?php
echo wp_kses_data( get_block_wrapper_attributes( array( 'class' => 'sc-choice ' ) ) );
- echo wp_kses_data( wp_interactivity_data_wp_context( array( 'price' => $price ) ) );
+ echo wp_kses_data( wp_interactivity_data_wp_context( array( 'price' => SureCartSupportPublicCatalogData::price( $price ) ) ) );
?>
data-wp-on--click="callbacks.setPrice"
data-wp-class--sc-choice--checked="state.isPriceSelected"
--- a/surecart/packages/blocks/Blocks/Form/Block.php
+++ b/surecart/packages/blocks/Blocks/Form/Block.php
@@ -4,6 +4,7 @@
use SureCartModelsManualPaymentMethod;
use SureCartModelsProcessor;
+use SureCartSupportPublicCatalogData;
use SureCartBlocksBlocksBaseBlock;
/**
@@ -52,7 +53,8 @@
'checkout' => [
'formId' => $attributes['form_id'] ?? $sc_form_id,
'mode' => apply_filters( 'surecart/payments/mode', $attributes['mode'] ?? 'live' ),
- 'product' => $attributes['product'] ?? [],
+ // Serialized into public page state — strip private catalog fields.
+ 'product' => PublicCatalogData::product( $attributes['product'] ?? [] ),
'currencyCode' => $attributes['currency'] ?? SureCart::account()->currency,
'groupId' => 'sc-checkout-' . ( $attributes['form_id'] ?? $sc_form_id ),
'abandonedCheckoutEnabled' => ! is_admin(),
--- a/surecart/packages/blocks/Blocks/PriceChoice/Block.php
+++ b/surecart/packages/blocks/Blocks/PriceChoice/Block.php
@@ -3,6 +3,7 @@
namespace SureCartBlocksBlocksPriceChoice;
use SureCartModelsPrice;
+use SureCartSupportPublicCatalogData;
use SureCartBlocksBlocksBaseBlock;
/**
@@ -42,8 +43,8 @@
'sc-price-choice',
'#sc-price-choice-' . (int) self::$instance,
[
- 'price' => $price->toArray(),
- 'product' => $price->product->toArray(),
+ 'price' => PublicCatalogData::price( $price ),
+ 'product' => PublicCatalogData::product( $price->product ),
]
);
--- a/surecart/packages/blocks/Blocks/ProductCollection/Block.php
+++ b/surecart/packages/blocks/Blocks/ProductCollection/Block.php
@@ -2,6 +2,7 @@
namespace SureCartBlocksBlocksProductCollection;
+use SureCartSupportPublicCatalogData;
use SureCartBlocksBlocksProductItemListBlock as ProductItemListBlock;
/**
@@ -75,10 +76,10 @@
)
);
- // get the product for each post.
+ // get the product for each post, stripped for public serialization.
$products = array_map(
function ( $post ) {
- return sc_get_product( $post );
+ return PublicCatalogData::product( sc_get_product( $post ) );
},
$product_query->posts ?? []
);
@@ -100,7 +101,7 @@
'paginationAutoScroll' => wp_validate_boolean( $attributes['pagination_auto_scroll'] ),
'searchEnabled' => wp_validate_boolean( $attributes['search_enabled'] ),
'sortEnabled' => wp_validate_boolean( $attributes['sort_enabled'] ),
- 'products' => ! SureCart::account()->isConnected() ? $this->getDummyProducts( $attributes['limit'] ) : $products->data,
+ 'products' => ! SureCart::account()->isConnected() ? $this->getDummyProducts( $attributes['limit'] ) : $products,
'collectionEnabled' => false,
'collectionId' => $this->getCollectionId( $attributes ),
'pageTitle' => get_the_title(),
--- a/surecart/packages/blocks/Blocks/ProductDonation/Block.php
+++ b/surecart/packages/blocks/Blocks/ProductDonation/Block.php
@@ -3,6 +3,7 @@
namespace SureCartBlocksBlocksProductDonation;
use SureCartModelsProduct;
+use SureCartSupportPublicCatalogData;
use SureCartBlocksBlocksBaseBlock;
use SureCartBlocksUtilBlockStyleAttributes;
@@ -48,11 +49,11 @@
),
'productDonation' => array(
$attributes['product_id'] => array(
- 'product' => $product->toArray(),
+ 'product' => PublicCatalogData::product( $product ),
'amounts' => $amounts,
'ad_hoc_amount' => null,
'custom_amount' => null,
- 'selectedPrice' => ( $product->active_prices || array() )[0] ?? null,
+ 'selectedPrice' => PublicCatalogData::price( ( $product->active_prices || array() )[0] ?? null ),
),
),
)
--- a/surecart/packages/blocks/Blocks/ProductItemList/Block.php
+++ b/surecart/packages/blocks/Blocks/ProductItemList/Block.php
@@ -2,8 +2,7 @@
namespace SureCartBlocksBlocksProductItemList;
-use SureCartModelsCollection;
-use SureCartModelsProduct;
+use SureCartSupportPublicCatalogData;
use SureCartBlocksBlocksBaseBlock;
/**
* ProductItemList block
@@ -268,10 +267,10 @@
)
);
- // get the product for each post.
+ // get the product for each post, stripped for public serialization.
$products = array_map(
function ( $post ) {
- return sc_get_product( $post );
+ return PublicCatalogData::product( sc_get_product( $post ) );
},
$product_query->posts ?? []
);
--- a/surecart/packages/blocks/Blocks/VariantPriceSelector/Block.php
+++ b/surecart/packages/blocks/Blocks/VariantPriceSelector/Block.php
@@ -4,6 +4,7 @@
use SureCartModelsComponent;
use SureCartModelsProduct;
+use SureCartSupportPublicCatalogData;
use SureCartBlocksBlocksBaseBlock;
/**
@@ -74,7 +75,7 @@
->id( 'sc-checkout-product-price-variant-selector-' . (int) self::$instance )
->with(
[
- 'product' => $product,
+ 'product' => PublicCatalogData::product( $product ),
'label' => ! empty( $attributes