Install SparkLayer on WooCommerce
Applies toWooCommerce
Before you start
Install
Connect
Widgets
Next steps
New to SparkLayer? How SparkLayer works explains the basics, and Storefront widgets shows what the widgets do.
Do you need a developer?
Usually not. You can install the plugin, connect your store and set up customers yourself, in WordPress and the SparkLayer Dashboard. On a block theme, the widgets are added for you. On other themes, adding them means editing theme files: our team can do it free of charge, or your developer can. Sections that need a developer are marked "for your developer".
Before you start
Check these in your WordPress admin before you install. It's also worth reading WooCommerce limitations.
- WooCommerce 9 or later, on WordPress 6 or later, with PHP 8.2 or later. WooCommerce (opens in a new tab) must already be installed on your WordPress site.
- HTTPS turned on for your store. The plugin only works over HTTPS.
- A permalink setting other than Plain in WordPress, at Settings,Permalinks, so the plugin can connect to WordPress and WooCommerce.
- A unique SKU on every product, because SparkLayer stores B2B prices by SKU. See Add SKUs to your products.
- A payment method. On a test store, turn on an example payment method in WooCommerce,Settings,Payments.
- Shipping rules set up in WooCommerce,Settings,Shipping, or in SparkLayer's own shipping, so orders can be placed.
Once SparkLayer is running, you'll mostly use three areas of WordPress: Products for products and SKUs, Users for B2B customers, and Orders for B2B orders.
Add SKUs to your products
- In WordPress, go to Products and edit a product.
- For a simple product, enter the SKU under Product data > Inventory.
- For a variable product, open Product data > Variations and enter a different SKU for each variation.
- Update the product.
Install SparkLayer
Upload the SparkLayer plugin to your WordPress site, then create your SparkLayer account.
- Ask our support team for the SparkLayer plugin for WooCommerce. They send you the plugin's .zip file.
- Upload and install the plugin on your WordPress site, as you would any plugin you upload yourself. See WordPress's guide to installing a plugin (opens in a new tab).
- Register for SparkLayer (opens in a new tab) to create your SparkLayer account.
Connect your store
Connect SparkLayer to WooCommerce with a REST API key: a key and secret, created in WooCommerce, that let SparkLayer read and update your store. You don't need to write any code to create one. If you get stuck, our support team can help.
- In the SparkLayer Dashboard, go to Integrations,Platform (opens in your SparkLayer Dashboard in a new tab). Under Your platform, select WooCommerce (early access).
- Enter your store URL: the address of the site you're installing SparkLayer on, such as
www.mystore.com. - In WordPress, go to WooCommerce,Settings,Advanced,REST API and click Add key.
- Give the key a description you'll recognise, such as SparkLayer API, set Permissions to Read/Write, and click Generate API key.
- Copy the Consumer key and Consumer secret that WooCommerce shows. WooCommerce only shows them once, so keep the page open until you've pasted them.
- Back in the SparkLayer Dashboard, paste them into WooCommerce API Key and WooCommerce API Secret, then click Save.
- Wait a few seconds while SparkLayer connects to your store and sets up the plugin.
Your store is now connected, and SparkLayer starts syncing your products. The plugin's settings are in WordPress at WooCommerce,Settings,Integrations,SparkLayer B2B. Next, give your B2B customers a role.
Give customers a B2B role
SparkLayer only syncs WordPress users with a role that starts with SparkLayer B2B. Each SparkLayer customer group has its own role. For the base customer group, it's SparkLayer B2B: Base.
- In WordPress, go to Users. Click Add User, or edit an existing customer.
- Make sure the customer has a complete address, with every address field filled in. Keep a note of their email address: they sign in with it.
- Set Role to the SparkLayer role for the customer's group, such as SparkLayer B2B: Base or SparkLayer B2B: VIP Group.
- Save the user.
When the customer signs in, they get the rules of that customer group. If you create another customer group in SparkLayer, update the role on the customers who belong to it.
Check a customer has synced
- In the SparkLayer Dashboard, go to Customers (opens in your SparkLayer Dashboard in a new tab).
- Search for the customer by name or email. If they're listed, they've synced.
- Click View to check their details. Under Identifiers, the Platform ID is their WordPress user ID: for example,
3in?user_id=3at the end of the user's page URL in WordPress.
If some customers couldn't sync, a banner at the top of Customers (opens in your SparkLayer Dashboard in a new tab) says so: click Show errors to see who and why. See Product and customer sync for more.
Add the widgets
If your theme supports blocks, the plugin adds the SparkLayer widgets (the frontend interfaces) to your store automatically. To check, sign in to your store as a B2B customer and open a product page. You should see your B2B prices.
If the widgets don't appear, or you'd rather place them yourself, they need adding to your theme files. You don't have to edit any code yourself. Choose one option:
| Option | How |
|---|---|
| Ask us to add them | Our team adds them free of charge. Go to Storefront,Widgets (opens in your SparkLayer Dashboard in a new tab) and click Request installation. See Request free installation. |
| Ask your developer | Pass them the steps below. |
Add the widgets to your theme (for your developer)
These steps edit your theme's code. Pass them to your developer.
Check the Core Script
The Core Script turns SparkLayer on in your store. The plugin adds it to your pages automatically, as long as your theme calls wp_head() in the <head> section of its template. To pin a Core Script version, use Version for this store at Storefront,Widgets,Core script version (opens in your SparkLayer Dashboard in a new tab).
Add the product detail interface
The product detail interface shows a B2B customer their prices and a way to order on each product page. Add this snippet to your product page template:
<spark-pdp parent-id="<?php echo absint( $product->get_id() ); ?>"></spark-pdp>Where it goes depends on your theme. Look for files such as woocommerce/single-product/add-to-cart/variable.php and woocommerce/single-product/add-to-cart/simple.php.
Check the product card interface
The product card interface shows B2B prices on collection pages. It should be added automatically. If it isn't, add this snippet to the template that renders products on your collection pages:
<spark-product-card parent-id="<?php echo absint( $product->get_id() ); ?>"></spark-product-card>Hide retail elements from B2B customers
If you're adding SparkLayer to an existing store, hide anything B2B customers shouldn't see, such as retail prices, quantity selectors, product options and buy buttons. Add data-spark="b2c-only" to each of those elements in your templates, or list them in CSS Hidden Selectors (see the next step). See the frontend integration guide.
Add your CSS (optional)
In WordPress, go to WooCommerce,Settings,Integrations,SparkLayer B2B and use these settings. The CSS you add here only loads when a B2B customer signs in.
| Setting | What it does |
|---|---|
| CSS Overrides | Changes SparkLayer's default styling, such as colours and fonts, with CSS variables like --spark-primary-color: #000000;. Start from the recommended starting CSS, without its <style> tags. |
| CSS Hidden Selectors | A comma-separated list of CSS selectors, such as .my-class, #my-id, for elements to hide while a B2B customer is signed in, such as a retail banner. |
When you've finished, check your setup against the frontend integration guide. See Storefront for the other settings you can turn on.
Next steps
Once your customers are syncing and the widgets are in place, set up your prices and rules in the SparkLayer Dashboard.
- Create a price list. Go to Pricing,Price lists (opens in your SparkLayer Dashboard in a new tab) and click Create price list. An automatic price list applies a discount to your WooCommerce price or your RRP price. A manual one uses prices you upload by CSV, including quantity pricing. See Managing pricing.
- Set up your customer groups. Go to Customers,Groups (opens in your SparkLayer Dashboard in a new tab). Use the base customer group, or click Create customer group for customers who need different rules. Choose each group's price lists, payment methods and order limits. You can manage a group's rules once at least one customer has its role. See Customer groups.
- Place a test order. Sign in to your store as a customer with a SparkLayer B2B role and check your prices. Place a test order with each payment method you offer. See How B2B orders arrive in WooCommerce.
- Invite your customers. Work through the steps at Home,Setup (opens in your SparkLayer Dashboard in a new tab), then let customers know, for example with a newsletter. The Launch checklist has example messages.
These steps match Get started on other platforms. When you're ready to go live, work through the launch checklist:
Test your setup, invite your first customers and go live
Create a price list for each pricing tier you offer
Choose each group's price lists, payment methods and order rules
How B2B orders arrive in WooCommerce
Every order goes to WooCommerce,Orders. Its status depends on the payment method the customer chose:
| Payment method | What the customer does | Order status in WooCommerce |
|---|---|---|
| Pay on Account | Checks out without entering payment details. | Pending payment. Mark it as paid once you've received payment. |
| Pay by Invoice | Checks out without entering payment details. | Pending payment. Mark it as paid once you've received payment. |
| Pay Online by Card | Goes to the WooCommerce checkout and pays straight away, with any payment method you've set up (such as card or PayPal). | Completed, if your store is set up for this. Ready to fulfil. |
In customer groups, Pay Online by Card is called Card at checkout, Pay by Invoice is Pay by invoice and Pay on Account is Payment on account. For offline payment methods, take payment in your WooCommerce admin or offline, for example by bank transfer.
Each order also has a SparkLayer Order Information section, which shows the payment method the customer used.
More settings on WooCommerce
Stock levels
SparkLayer can show stock levels in several ways. To show stock numbers, such as 100, turn on Manage stock in WooCommerce,Settings,Products,Inventory. To show stock on product cards too, use the settings in WooCommerce,Settings,Integrations,SparkLayer B2B.
Pre-orders
SparkLayer supports pre-orders (also called back orders). When a product is on pre-order, B2B customers see a pre-order message on the product page and can still buy it. See Stock display.
Tax
SparkLayer uses the tax rules you've set up in WooCommerce. See WooCommerce's guide to setting up taxes (opens in a new tab).
SparkLayer shipping
By default, B2B orders use your WooCommerce shipping methods. To use SparkLayer's own shipping rules instead, go to Settings,Shipping (opens in your SparkLayer Dashboard in a new tab), tick Use SparkLayer shipping rates and create your shipping methods.
JavaScript options (for your developer)
JavaScript options are small scripts that change how the widgets behave. You don't need any of them to get started. Some settings are made in JavaScript, using Spark Options.
On WooCommerce, add them in WooCommerce,Settings,Integrations,SparkLayer B2B, under Core Script Options. If you use more than one option, combine them into one object.
This example adds a required Preferred Shipping Date field to the checkout and sets the link to your terms and conditions.
{
termsAndConditionsLink: "/policies/terms-of-service",
checkoutCustomElements: [
{
name: 'shipping-date',
translations: {
en: {
title: 'Preferred Shipping Date',
detail: 'Shipping unavailable on weekends.',
},
},
attributes: {
required: true,
type: 'date',
},
},
],
}This example sends signed-in customers who open a page matching /account to /index instead.
{
accountRedirect: {
urlRegex: /\/account/g,
goTo: "/index", // page to redirect logged in users to
},
}If your store uses a dark theme, dark mode changes the widgets' colours so text stays readable.
{
display: {
darkTheme: true,
},
}FAQs and troubleshooting
Check that your store uses HTTPS, that the WordPress permalink setting isn't Plain, and that the REST API key has Read/Write permissions. If it still won't connect, contact our support team.
Check that the customer's WordPress user has a SparkLayer B2B role, and that the product has a SKU with a price in the customer's price list. Then check the customer has synced.
See Troubleshooting for common issues such as pricing problems, and WooCommerce FAQs for questions about plans, products and orders. You can also contact our support team.
Last updated