Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable/disable ajax cart based on Woo settings and added a filter to … #713

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions woocommerce/wc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@

/**
* Register Ajax Cart
* Allow users to edit/disable entire AJAX functionality in child theme
*
* Enabled/Disabled based on the setting in backend under WooCommerce > Settings > Products > Enable AJAX add to cart buttons on archives.
* Disable file via filter add_filter('bootscore/load_ajax', '__return_false');
*/
if (!function_exists('register_ajax_cart')) :

function register_ajax_cart() {
require_once('inc/ajax-add-to-cart.php');
function register_ajax_cart() {
if (apply_filters('bootscore/load_ajax', true)) {
$ajax_cart_en = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart');
if ($ajax_cart_en) {
require_once('inc/ajax-add-to-cart.php');
}
}

add_action('after_setup_theme', 'register_ajax_cart');

endif;
}
add_action('after_setup_theme', 'register_ajax_cart');