Skip to main content

Installation

The Spiff Commerce Magento plugin (Spiff_Personalize) adds a personalization button to your product pages, adds the customer's design to the cart, and sends the order to Spiff Commerce when it is placed. The source is public at github.com/spiffdev/magento-plugin, and the module is also listed on the Adobe Commerce Marketplace.

note

The plugin currently launches the hosted experience for a single design and records that design's transaction ID against the cart item. It does not yet use activations or bundles.

Requirements​

  • Magento 2 (the module uses declarative schema and data patches, so 2.3 or later; it is written against 2.4.x APIs).
  • An integration in the Spiff Commerce Hub, and its application key.
  • Each product you want to personalize must exist as an integration product in the Hub.

Installing the module​

Install the module from the Adobe Commerce Marketplace using the instructions on its listing, or copy the Spiff/Personalize directory from the repository into app/code/Spiff/Personalize in your Magento installation. Then enable the module and rebuild:

bin/magento module:enable Spiff_Personalize
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
bin/magento cache:flush

setup:upgrade adds a spiff_transaction_id column to quote items and order items, and creates three product attributes in the General group: Enable Spiff, Spiff Integration Product ID and Use Spiff Price.

warning

The module declares a load-order dependency on MageWorx_OrderEditor. If that extension is not installed in your store, review etc/module.xml before enabling the module.

Configuration​

In the Magento admin, go to Stores > Configuration > Spiff Personalize > Spiff API Settings and set:

SettingDescription
Application keyThe application key from your integration in the Spiff Commerce Hub.
RegionThe region your Spiff Commerce account is hosted in: Australia (AU) or United States (US).

Settings can be set at the default, website or store scope.

Enabling personalization on a product​

Edit the product and, in the General group, set:

AttributeDescription
Enable SpiffReplaces the product's Add to Cart button with a Personalize Now button.
Spiff Integration Product IDThe integration product ID from the Hub (the ID shown for the product on your integration's Products section).
Use Spiff PriceUse the price calculated by Spiff Commerce for the cart item, instead of the Magento price.

The product also needs a custom text option, which the plugin uses to hold the transaction ID of the customer's design.

To personalize a different Spiff product from a Magento product, set a redirect_product attribute on the Magento product to the SKU of the product to use. This attribute is not created by the plugin and must already exist in your store.

How it works​

  1. On a product page with Enable Spiff set, the plugin loads https://assets.us.spiffcommerce.com/api.js and replaces Add to Cart with the Personalize Now button.
  2. When the customer presses the button, the plugin launches a hosted experience for the product's Spiff Integration Product ID.
  3. When the customer finishes, the plugin adds the item to their Magento cart through the module's REST endpoints and stores the design's transaction ID against the cart item, then redirects the customer to /checkout/cart.
  4. The cart shows the design's preview image and selections, which the plugin fetches from Spiff Commerce using the transaction ID.
  5. When the order is placed, the plugin copies the transaction ID to the order item and sends the order to Spiff Commerce, including the Magento order number, customer details, addresses, discount codes, and each design's transaction ID and quantity. The transaction ID is also shown on the order item in the admin.

Orders are sent synchronously as part of checkout. Failures are logged to var/log/custom.log and are not retried, so check this log if an order does not appear in the Hub.

Customizing​

You can override the module's templates in your theme:

  • Spiff_Personalize::product/view/addtocart.phtml: the personalize button and launch script.
  • Spiff_Personalize::cart/item/default.phtml: how designs render in the cart.
  • Spiff_Personalize::options/type/text.phtml: the product's text option.

The button text and styling are set in addtocart.phtml.