Button Mode: A Purchase Button Where You Choose
Shows a RAKUFUN purchase button at a spot you choose on your page (for example below the price, or next to your add-to-cart button). When users click it, the RAKUFUN product page opens in a new tab to complete the purchase.
When to use it: you want the purchase entry next to the product information rather than at the bottom of the page. The button's style and text are set by the SDK; if you want to use your own button design, see Custom Mode.
Live Demo
🎨 按钮模式实时演示
查看购买按钮如何渲染到容器中
SDK 会在此容器中渲染购买按钮
Integration Steps
Step 1: Add an empty div where you want the button
<div class="product-info">
<h1>Sony WH-1000XM5 Wireless Headphones</h1>
<p class="price">¥54,800</p>
<!-- The purchase button appears here -->
<div class="rakufun-sdk-embed-button"></div>
</div>2
3
4
5
6
7
The class name must be rakufun-sdk-embed-button. You can add more than one on the same page; a button appears in each.
Step 2: Include the SDK, switch to button mode, and set the product information
Put the following on the page, usually right before </body>:
<script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>
<script>
// Switch to button mode (without this line, the bottom panel is shown instead)
rakufun.setUIMode('button');
// Tell the SDK which product this is
rakufun.setUIProductData({
url: window.location.href, // Address of the current product page
title: 'Sony WH-1000XM5 Wireless Headphones', // Product name
price: '54800', // Price, digits only, no ¥ or commas
images: ['https://example.com/headphones.jpg'], // Product images, full addresses
description: 'Industry-leading noise cancellation' // Product description (optional)
});
</script>2
3
4
5
6
7
8
9
10
11
12
13
14
For the other fields you can pass, see API Reference - Product Information Fields.
Button Style
The button's style is provided by the SDK, with hover and click effects, consistent with the RAKUFUN brand. The button text is fixed to "Ship internationally via RAKUFUN" and can't be changed for now.
FAQ
The button doesn't show?
Check in this order:
- Are you testing from Japan? It's hidden by default for Japanese IPs. For testing, call
rakufun.enableDebug()to show it temporarily, and remove it after testing - Is the container's class name
rakufun-sdk-embed-button, with no typos? - Is
rakufun.setUIMode('button')called? - Open the browser console and check whether the SDK loaded and whether there are errors
Want to show a confirmation dialog after the click, before RAKUFUN opens?
Use setUICartHandler. The purchase continues only if the function returns true; any other value cancels it:
rakufun.setUICartHandler(async (product) => {
return confirm(`Confirm purchase of ${product.title}?`);
});2
3
Other Integration Options
- Default Mode - Purchase panel shown automatically at the bottom of the page, the fastest integration
- Banner Mode - Shows a banner where you choose
- Custom Mode - Use your own button
Questions? Contact us: service@rakufun.com