Skip to main content

Web2PrintModifierAttributeController

You get this controller when useAttribute(...) resolves a Web2Print modifier attribute. A modifier attribute adjusts a single print property (opacity, a left/right position, a border width, or a boolean flag like flip_x) and is backed by value entities that you select by their cid.

import { useAttribute } from "@expivi/product-configurator";

const attribute = useAttribute(configurator, attributeCid);

Reading the modifier type and selecting a value

Use the type helpers to decide how to render the control, then apply a value entity with setValue(cid).

const type = attribute.getAttributeModifierType();

if (attribute.isFloatType(type)) {
// Render a slider for opacity / left / right / border_width
} else if (attribute.isBooleanType(type)) {
// Render a toggle for flip_x / flip_y / visible
}

// Apply a value entity
const value = attribute.allValues[0];
attribute.setValue(value.cid);

API

getAttributeModifierType(): string

Returns the modifier type from the attribute settings, defaulting to "opacity" when none is set.

attribute.getAttributeModifierType(); // e.g. "opacity"

isFloatType(type?: string): boolean

Returns true when the modifier is float-based (opacity, left, right, border_width). Uses the passed type, or the attribute's own type when omitted.

isBooleanType(type?: string): boolean

Returns true when the modifier is boolean-based (flip_x, flip_y, visible). Uses the passed type, or the attribute's own type when omitted.

setValue(cid) selects the modifier value entity whose cid matches and stores its config.value. For all other members, see the Common Attribute API.