How to Disable add to cart button via custom checkbox

Disable add to cart button via custom checkbox in WooCommerce product settings Explanation via comment tags added in the code To add a checkbox to the inventory product options, use: [php]// Add checkbox function action_woocommerce_product_options_inventory_product_data() { // Checkbox woocommerce_wp_checkbox( array( ‘id’ => ‘_prevent_add_to_cart_button’, // Required, it’s the meta_key for storing the value (is checked or … Read more

How to add a radio button with price on product page

How to add a radio button with price on product page? WordPress woocommerce Add to follows code snippets to achieve your work: [php]function add_custom_fees_before_add_to_cart() { global $product; $args = array( ‘type’ => ‘radio’, ‘class’ => array( ‘form-row-wide’ ), ‘options’ => array( ” => ‘No Option’, ’10’ => ‘Option 1 ($10)’, ’30’ => ‘Option 2 ($30)’, … Read more

How to Add a checkout birth date required field with adult control in Woocommerce

The following code adds a billing birth date field and will check customer age avoiding checkout if customer is not at least 18 year old: [php]// Adding a custom checkout date field add_filter( ‘woocommerce_billing_fields’, ‘add_birth_date_billing_field’, 20, 1 ); function add_birth_date_billing_field($billing_fields) { $billing_fields[‘billing_birth_date’] = array( ‘type’ => ‘date’, ‘label’ => __(‘Birth date’), ‘class’ => array(‘form-row-wide’), ‘priority’ … Read more

Woocommerce rating not showing in new custom theme

I am working on to new custom theme. I have installed woocommerce plugin. I have import product from xml files. I had tried to test rating functionality. Its working on wordpress default theme twentytwelve, twentysixteen. etc. But when I switched to my custom theme. comment section not showing rating. Take a look on screenshot. Comment … Read more

Get Yoast SEO title for custom taxonomy – WordPress

I’m trying to get the SEO title from a custom taxonomy. Here’s my current code for it: $my_yoast_wpseo_title = get_term_meta( $term_id, ‘_wpseo_title’, true ); if( $my_yoast_wpseo_title ){ echo $my_yoast_wpseo_title; } else { echo ‘No title’; } It doesn’t work. So I tried different meta keys like _yoast_wpseo_title and everything I could find in their docs and other … Read more

Return the ID of the selected terms to array

My terms have an additional ACF true/false field. I need to get a list of all the term IDs with the field enabled and return a list of these IDs. So far I have achieved such a code, but it returns me only one ID: [php]function terms_exclude_id_func() { $terms_control = get_terms([ ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ … Read more

What are the different ways to detect home page in wordpress

What are the different ways to detect wordpress homepage except is_front_page() and is_home() Best Answer is_front_page() is what you want. I assume, by the fact that is_home() is not working, that your home page is static, according to the settings in wp-admin. is_home() returns true on your main blog page whereas is_front_page() returns true on which ever page is defined as your front page, … Read more

Why shouldn’t Use mysql_* functions in PHP

What are the technical reasons for why one shouldn’t use mysql_* functions? (e.g. mysql_query(), mysql_connect() or mysql_real_escape_string())? Why should I use something else even if they work on my site? If they don’t work on my site, why do I get errors like Warning: mysql_connect(): No such file or directory Best Answer The MySQL extension: Is not under active development Is officially deprecated as … Read more

How to WooCommerce Change Loading Spinner Icon

I am trying to change the WooCommerce loading spinner icon. It’s defined in the woocommerce.css: [php].woocommerce .blockUI.blockOverlay::before { height: 1em; width: 1em; display: block; position: absolute; top: 50%; left: 50%; margin-left: -.5em; margin-top: -.5em; content: ”; -webkit-animation: spin 1s ease-in-out infinite; animation: spin 1s ease-in-out infinite; background: url(../images/icons/loader.svg) center center; background-size: cover; line-height: 1; text-align: … Read more