After researching this issue I found code that will add the price to the "Add to cart" button like this:
[ $50 Add to cart ]
The code for some reason does not use the ajax class so when the button is clicked the page reloads. The normal default button will use an ajax class so when it's clicked it does not reload the page but will show a message that it's been added to the cart.
I am overriding the file add-to-cart.php by adding it to my theme at \woocommerce\loop\add-to-cart.php
Here's the code that does not use ajax class:
echo apply_filters( 'woocommerce_loop_add_to_cart_link',
sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button product_type_simple add_to_cart_button ajax_add_to_cart">%s %s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
$product->is_purchasable() ? 'add_to_cart_button' : '',
esc_attr( $product->product_type ),
$product->get_price_html(),
esc_attr( isset( $class ) ? $class : 'button' ),
esc_html( $product->add_to_cart_text() )
),
$product );
How can I modify this to use the ajax class of the default add to cart button?
Thanks in advance