This tutorial explains how to create a custom Add to Cart button using FluentCart and how to find the required IDs.
Add the following HTML code to any page where you want the button to appear:
<button
data-fluent-cart-add-to-cart-button
data-cart-id="3"
data-product-id="15"
data-variation-type="simple_variations"
aria-label="Add To Cart"
data-action-name="single_product_page_cart_updated_0"
data-error-action-name="single_product_page_cart_updated_0"
>
<span class="text">Add To Cart</span>
</button>You must replace:
data-product-id→ Your product's Product IDdata-cart-id→ Your product's Variation ID
- Go to your WordPress admin dashboard.
- Navigate to FluentCart → Products.
- Click Edit on your product.
- The Product ID is visible on the edit screen, as shown below:
Replace data-product-id with this value.
- Open your product in FluentCart.
- Copy the Direct Checkout URL, as shown below:
The URL will look like this:
https://fluentcart.top/?fluent-cart=instant_checkout&item_id=138&quantity=1
In this URL:
item_id=138is the Variation ID
Replace data-cart-id with this value.
| Attribute | Value to Use |
|---|---|
data-product-id |
Product ID from the product edit screen |
data-cart-id |
item_id value from the direct checkout URL |
Once both IDs are set correctly, the custom Add to Cart button will work as expected.