E-Commerce Plugin Reference — Soft8Soft
Description: Puzzles from this plugin are used for implementing WooCommerce product 3D views and configurators, as well as for creating standalone order/inquiry forms.

# E-Commerce Plugin

This stock plugin includes puzzles that can be used for implementing various e-commerce applications. It supports basic PayPal payments, WooCommerce 3D product views and configurators, as well as advanced ordering puzzles which work with WordPress-based e-commerce solution shipped with Verge3D.

## Contents

- PayPal Puzzle
  - paypal create order
- WooCommerce Puzzles
  - connect to WooCommerce
  - product info
  - product attribute
  - product component
- WordPress Order Form Puzzles
  - place order
  - place order +
  - order item (sku, qty)

#

## PayPal Puzzle

#

### paypal create order

Places a PayPal order. This puzzle is the simplest e-commerce solution possible because it does not require any server-side configuration. To use it you only need verified PayPal business account.

client ID
  PayPal business account client ID. Use the following page to obtain it. For testing purposes there are Sandbox credentials, while for real selling you need to perform additional steps to receive Live credentials.
title
  Product title.
item price
  Product item price.
currency
  Currency.
quantity
  Amount of product.
on success do
  Puzzles in this slot are executed upon successful transaction.
on error do
  Puzzles in this slot are executed upon errors (insufficient funds or so).

#

## WooCommerce Puzzles

#

### connect to WooCommerce

Connects to the WooCommerce system and starts receiving product information.

For usage example, check out the Drink Shop demo (source files available in the Asset Store).

See this tutorial for more details.

#

### product info

Returns a dictionary with product information retrieved by the connect to WooCommerce puzzle:

The dictionary contains the following fields:

price
  Price for the product option selected by the customer, e.g. 12.
quantity
  Quantity of the product items selected by the customer, e.g. 2.
sku
  Stock keeping unit for the product option selected by the customer.
name
  The name of the product as it will be seen in the shop cart, e.g. "Spinner - Yellow, Large".
attributes
  A dictionary with attribute names/values pairs for the product option selected by the customer, e.g. {color: "Yellow", size: "Large"}.
weight
  Physical product weight for the product option selected by the customer.
length, width, height
  Physical product dimensions for the product option selected by the customer.
type
  Product type as specified in WooCommerce admin panel, one of the following: "variable", "simple", "group", "external", or "composite".
children
  Only available for "group" products. Returns list with information on the per-subproduct basis.
components
  Only available for "composite" products. Returns list with information on the per-component basis. For simplicity you can use the product component puzzle to obtain this info.
status
  Server response: "ok" or "error".

#

### product attribute

Returns the value for an attribute of the product option selected by the customer, e.g. "Yellow" for attribute "color". If the attribute does not exist, the puzzle returns `""` (empty string).

Most frequently, this puzzle used to obtain the currently selected variation of a "variable" product. The name of the attribute passed is matched in a case-insentitive manner, e.g. "Color", "color", or "COLOR" represent the same attribute.

See this tutorial for more details.

#

### product component

Returns a value from a product component provided by the WooCommerce Composite Products extension.

For your convenience, you can specify either component name (title) (e.g. "Drawer Top") or a component ID (e.g. "1685435951") as the first parameter.

You can retrieve one of the following values from the component:

product name
  Name of the product selected in the component. Equal to `""` (empty string) if no product selected.
sku
  SKU of the product selected in the component. Equal to `""` (empty string) if no product selected, or if you have no SKU assigned for the product.
quantity
  Product quantity.
type
  Product type: "simple", "variable", or "none" if no product was selected.
weight
  Product weight. Equal to 0 (zero) if no weight was specified for the product.
width
  Product width. Equal to 0 (zero) if no width was specified for the product.
height
  Product height. Equal to 0 (zero) if no height was specified for the product.
length
  Product length. Equal to 0 (zero) if no length was specified for the product.
attributes
  Dictionary with attributes assigned on the selected product. In most cases, this value is used to obtain attributes for the currently selected variation of the "variable" products.
component title
  Component name (title), e.g "Drawer Top". Not to be confused with the product name.
component id
  Component ID, e.g "1685435951".

#

## WordPress Order Form Puzzles

#

### place order

Composes and submits an order form to a specified URL. By default the order form is submitted to the sandbox ordering page.

For usage example, check out the Ring demo (source files available in the Asset Store).

Verge3D comes with a free WordPress plug-in that is able to handle requests submitted by this puzzle. Upon receiving such a request, this WordPress plug-in renders a page with an extended form supplemented with contact info, comments fields, and optional screenshot. Filled out form is finally submitted by the customer and a new order is created in WordPress admin interface.

send to
  The URL of the order form provided by the WordPress plugin. Please refer to the following guide for setup information.
content
  Order contents in human-readable form.
item price
  Product item price.
quantity
  Amount of product.
make screenshot
  Make application screenshot and attach it to the order. Be sure to enable screenshots in the configure application puzzle otherwise the screenshot may be rendered in black.

It's up to you (or sales manager) to verify correctness of the order content and price. Though very unlikely, a hacker may malform content submitted by this puzzle and try to purchase a product for lesser price. To prevent it, you need to verify your orders by using the place order + puzzle which rely on product info assigned on the server.

#

### place order +

Composes and submits an order form to a specified URL. This puzzle works similar to place order, but has more features, greater security, and allows for customizations.

For usage example, check out the Recliner demo (source files available in the Asset Store).

send to
  The URL of the order form provided by the WordPress plugin. Please refer to the following guide for setup information.
item(s)
  Order item or a list of order items. See below for more info.
attachment(s)
  Order attachment or a list of order attachments. Attachment is a Data URL link which represents a screenshot, image, sound, video, PDF, text, or a glTF model.

Example usage:

#

### order item (sku, qty)

Order item to be used in the place order + puzzle.

sku
  The SKU (stock keeping unit) of the product registered by WordPress plugin. Please refer to the following guide to find out how setup products.
quantity
  Amount of product.

## Having Troubles with Puzzles?

Seek help on the forums!