@3dsource/metabox-front-api
    Preparing search index...

    Class SetProduct

    Represents a command to set a product by its ID. This action sends a message to the Metabox API to set a product using the provided product ID. To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.

    Sets the active product in the Basic Configurator by its UUID. Triggers a full state update including available materials, slots, showcase data, and environment compatibility.

    Selects which product to display in the 3D viewport. Takes a productId (UUID). Use to build product picker UIs, deep-link to specific products, or switch products programmatically based on external catalog selections. The configurator responds with a full ConfiguratorEnvelope via configuratorDataUpdated.

    Call api.sendCommandToMetabox(new SetProduct('product-uuid')). Get valid product IDs from configurator.products in the configuratorDataUpdated envelope. Subscribe to configuratorDataUpdated BEFORE sending the command. After switching products, material and environment selections may reset — re-apply them if needed.

    import { Communicator,ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
    window.env3DSource.apiReady = (api: Communicator) => {

    //Subscribe to the event before sending the command to ensure you capture the response
    api.addEventListener('configuratorDataUpdated', (data:ConfiguratorEnvelope) => {
    console.log('State updated after applied new product:', data);
    });

    api.sendCommandToMetabox(new SetProduct(
    'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
    ));
    };

    The product ID.

    Index

    Constructors

    Properties

    Constructors

    • Parameters

      • productId: string

      Returns SetProduct

    Properties

    data: ToMetaBoxMessageEnvelope

    The message envelope populated by subclass constructors and sent via Communicator.sendCommandToMetabox.