Woocommerce – disable «place order» until user checks Privacy Policy

I think you should jQuery to enable and disable the checkout button. Please try this script. Put this script in the footer.php. jQuery(window).on(‘load’,function(){ setTimeout(function(){ jQuery(‘#payment #place_order’).attr(“disabled”,”disabled”); console.log(‘Hello’); },1000); }); jQuery(document).on(‘change’,’#privacy_policy_field #privacy_policy’,function() { var ischecked= jQuery(this).is(‘:checked’); if(!ischecked){ jQuery(‘#payment #place_order’).attr(“disabled”,”disabled”); console.log(‘unchecked’); }else{ jQuery(‘#payment #place_order’).removeAttr(“disabled”); console.log(‘checked’); } }); Note: This is tested script for your code.

Getting categories id for all products in cart

Use $cart_item[‘data’]->get_category_ids() to retrieve the category IDs: $category_ids = $cart_item[‘data’]->get_category_ids(); // array The category_ids you see is not a direct item in the $cart_item array: var_dump( $cart_item[‘category_ids’] ); // null and PHP throws a notice It’s an item in a protected property of the product data ($cart_item[‘data’]) which is an object, or a class instance … Read more

How to remove the woocommerce_checkout_process action hook in woocommerce if particular project in cart [closed]

try this below code in your function.php file or in your plugin add_action(“init”, function () { // removing the woocommerce hook foreach( WC()->cart->get_cart() as $cart_item ){ $product_id = $cart_item[‘product_id’]; if($product_id!=’19’) { remove_action(‘woocommerce_checkout_process’, ‘my_custom_checkout_field_process’); } } });

Woocommerce Shop Price Position

It appears but above the Title and outside the custom div. What am I doing wrong? It’s because woocommerce_template_loop_price() echoes the output. So to fix the problem, just use ?> HTML here <?php instead of echo ‘HTML here’;: function custom_woocommerce_template_loop_product_title() { ?> <div class=”custom-title-wrapper”> <h1 class=”woocommerce-loop-product__title custom-loop-product-title”><?php the_title(); ?></h1> <h2><?php woocommerce_template_loop_price(); ?></h2> </div> <?php } … Read more

Display WooCommerce only in stock sizes product attribute on shop page

To get only available “In stock” displayed sizes, you need something a little more complicated and different: add_action( ‘woocommerce_after_shop_loop_item_title’, ‘display_instock_sizes’, 5 ); function display_instock_sizes() { global $product; if ( $product->is_type(‘variable’) ) { $taxonomy = ‘pa_size’; // The product attribute taxonomy $sizes_array = []; // Initializing // Loop through available variation Ids for the variable product … Read more