Add code to function.php files
/* Ajax Add to Cart button */
if ( ! function_exists( 'de_add_to_cart_button' ) ) {
function de_add_to_cart_button(){
if ( true === et_get_option( 'add_to_cart', false ) ) {
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );
}
}
add_action( 'init', 'de_add_to_cart_button' );
}
/* Add Show/Hide Add to Cart button option */
if ( ! function_exists( 'de_append_theme_customizer' ) ) {
function de_append_theme_customizer( $wp_customize ) {
$wp_customize->add_setting( 'et_divi[add_to_cart]', array(
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'et_divi[add_to_cart]', array(
'label' => esc_html__( 'Enable Add To Cart', 'Divi' ),
'section' => 'woocommerce_product_catalog',
'type' => 'checkbox',
) );
}
add_action( 'customize_register', 'de_append_theme_customizer' );
}
CSS code to Theme Option
.woocommerce ul.products li.product .button {
margin-top: 1em;
background-color: #8b312e;
color: #fff;
border-radius: 0px;
border-width: 0px;
}
.woocommerce-page a.button:after{
content: "\e079";
font-size: 20px;
padding-top: 5px;
padding-left: 5px;
}
.woocommerce-page a.button:after{
content: "\e079";
font-size: 20px;
padding-top: 5px;
padding-left: 5px;
}
.woocommerce a.added_to_cart{
color: #fefefe !important;
width: 50%;
margin-left: auto;
margin-right: auto;
float: right;
}
.woocommerce a.added_to_cart:after{
content: "\e079";
font-family: ETmodules!important;
font-size: 20px;
padding-top: 5px;
padding-left: 5px;
}
.woocommerce a.button.loading::after {
content: "\e02d";
font-size: 20px;
padding-top: 5px;
padding-left: 5px;
}
.woocommerce a.added_to_cart{
width: 50%;
margin-left: auto;
margin-right: auto;
float: left;
}
.woocommerce a.button.added::after {
content: "\e079";
font-family: ETmodules!important;
font-size: 20px;
padding-top: 5px;
padding-left: 5px;
}
.archive .woocommerce a.added_to_cart{
color: #000 !important;
float: left;
}