
Add Icon in the Add to Cart Button – Woocommerce
- No Bulky Libraries Used
- 3-Days Return Policy
- Easy to use
- No Bulky Libraries Used
- 3-Days Return Policy
- Easy to use
- No Bulky Libraries Used
- 3-Days Return Policy
- Easy to use
- No Bulky Libraries Used
- 3-Days Return Policy
- Easy to use
Product Description
ATC With Icon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
define(
'WOO_ATC_ICON_HTML',
'<i class="ri-handbag-line"></i>'
);
add_action( 'wp_enqueue_scripts', function () {
if ( is_product() ) {
wp_enqueue_style(
'remixicon',
'https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.min.css',
[],
'4.2.0'
);
wp_add_inline_style(
'remixicon',
'
.woo-atc-icon {
color: #fff;
// margin-right: 5px !important;
font-size: 18px !important;
}
.single_add_to_cart_button:not(.buy_now_button){
gap:10px;
}
'
);
}
});
add_action( 'woocommerce_before_single_product', function () {
ob_start( function ( $buffer ) {
if ( ! is_product() ) return $buffer;
// Allow only <i class="">
$icon_html = wp_kses(
WOO_ATC_ICON_HTML,
[
'i' => [
'class' => []
]
]
);
return preg_replace(
'/(<button[^>]*class=["\'][^"\']*single_add_to_cart_button[^"\']*["\'][^>]*>)(.*?)(<\/button>)/i',
'$1<span class="woo-atc-icon">' . $icon_html . '</span>$2$3',
$buffer
);
});
});
add_action( 'woocommerce_after_single_product', function () {
ob_end_flush();
});
Change Icon
Copy to clipboard
1
2
3
4
5
6
7
8
9
define(
'WOO_ATC_ICON_HTML',
'<i class="ri-shopping-cart-2-line"></i>'
);
// Example icons:
<!--<i class="ri-flashlight-line"></i>-->
<!--<i class="ri-handbag-line"></i>-->
Icon After ATC Text
1
$1$2<span class="woo-atc-icon">' . $icon_html . '</span>$3
Icon Before ATC Text
1
$1<span class="woo-atc-icon">' . $icon_html . '</span>$2$3
Additional CSS
1
2
3
4
5
6
7
8
9
10
11
.single-product .single_add_to_cart_button i {
color: #FFF !important;
display: inline-block !important;
margin-left: 5px !important;
<!--margin-right: 5px !important;-->
padding-left: 0 !important;
font-size: 18px !important;
line-height: 1 !important;
}
<!--Note : If your code styling doesn't work, add it to the customizer, Otherwise ignore this step-->
Reviews (0)
Add a review
Rating*
0/5
* Rating is required
Your review
* Review is required
Name
* Name is required
Email
* Email is required
Add photos or video to your review
Related products
-

Complete Checkout Page Customization
₹4,999Original price was: ₹4,999.₹3,499Current price is: ₹3,499.Rated 5.00 out of 5 -

Coupon Slider
₹1,499Original price was: ₹1,499.₹799Current price is: ₹799. -


Show/Hide Payment Methods based on countries
₹899Original price was: ₹899.₹499Current price is: ₹499. -


Anti Theft WordPress – Disable Right Click, Text Selection and Shortcuts
₹0

Reviews
There are no reviews yet