Request: Add data-product_sku to the "Add to Cart" links or allow customizing data attributes.
I really need to add product SKU to the Add to Cart links to use it in my JS code. That seemed to be easy because WooCommerce provides some helpful hooks, for example woocommerce_loop_add_to_cart_args or woocommerce_loop_add_to_cart_link. None of these works in BeTheme because the add to cart links are hardcoded in the the content-product.php file. The only way to add custom attributes to the add to cart link without modifying BeTheme is to apply the following hack. Could you see if you can rework the content-product.php and utilize the woocommerce_loop_add_to_cart_args when generating add to cart links?
function custom_add_to_cart_url( $url ) {
global $product;
return $url . '" ' . 'data-product_sku="' . $product->get_sku();
}
add_filter('add_to_cart_url','custom_add_to_cart_url' );
Comments
What you ask for, requires files customization what in reference to Item Support Policy is not allowed. So if you want to modify files and don't know how, you should contact your web developer. Item Policy says:
Item support does not include services to modify or extend the item beyond the original features, style, and functionality described on the item page. For customization services that will help you tailor the item to your specific requirements, we recommend contacting the author to see if they privately offer paid customisation services or checking out the great service providers on Envato Studio
thanks
post it here: https://forum.muffingroup.com/betheme/discussion/113/your-suggestions-for-future-updates#latest
We really appreciate this.
Thanks.