Skip to content

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 ​

html
<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>

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>:

html
<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>

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:

  1. 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
  2. Is the container's class name rakufun-sdk-embed-button, with no typos?
  3. Is rakufun.setUIMode('button') called?
  4. 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:

javascript
rakufun.setUICartHandler(async (product) => {
  return confirm(`Confirm purchase of ${product.title}?`);
});

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

Released under the MIT License