I have a problem that I can't solve, and I hope someone can help me. The company's online store is built with WordPress, WooCommerce, and Elementor.
I confess that I don't have much expertise in the WordPress environment!
Recently, for some reason I couldn't identify, the 'Add to Cart' button disappeared from the product page. I've tried various approaches to restore it, but without success. My last attempt was to edit the WooCommerce plugin. In a version used on my localhost, I added the code below to the file wp-content/plugins/woocommerce/single-product/single-product.php, and it worked, but in the production version, it doesn't work. The difference between the two versions is that the localhost version doesn't use Elementor.
global $product;
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 %s product_type_%s">%s</a>',
esc_url($product->add_to_cart_url()),
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
$product->is_purchasable() ? 'add_to_cart_button' : '',
esc_attr($product->get_type()),
esc_html($product->add_to_cart_text())
),
$product
);
What I'm trying to do is make WooCommerce recognize the single-product.php and disregard the page created in Elementor, which was previously used. Does anyone have an idea on how to force this behavior?
I'm using Woocommerce version 8.5.1, Wordpress 6.4.2 and PHP 7.4
I tried to directly modify the single-product.php file in the WooCommerce plugin, adding the purchase button next to the product image, but it had no effect whatsoever. It's as if I hadn't made any PHP modifications. Does anyone know why the single-product.php file is not being loaded?
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand