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

How to Access WooCommerce Order Details in Custom Plugin

actually i am creating a new plugin in this i want to get the order number and all other details but for now just the order number. For this i am using the following code which i get from Stackoverflow past answers. add_action( ‘wp_head’, ‘get_order_num’ ); function get_order_num($order_id) { global $woocommerce, $order; $order = new WC_Order($order->ID); print_r($order); die(); … 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

How to Change WooCommerce Checkout Layout

In the “woocommerce/templates/checkout” folder there is a file called “form-checkout.php”. Copy the contents of that file to “yourtheme/woocommerce/checkout/form-checkout.php” On line ~54 there is the following code: [php]<?php do_action( ‘woocommerce_checkout_order_review’ ); ?>[/php] Move that to just below: [php]<form name="checkout" method="post" class="checkout" action="<?php echo esc_url( $get_checkout_url ); ?>">[/php] and add: [php]<?php $order_button_text = apply_filters( ‘woocommerce_order_button_text’, __( ‘Place … Read more

Render WooCommerce Block ‘Product Filter – Attributes’ in code rather than via backend

Block content (including woocommerce blocks) can be rendered in a template via the do_blocks() function. The easiest way to generate the block code is to create a new post/page, insert the block you want, configure the attributes/settings as needed, then switch from the Visual editor to the Code editor (shortcut: Ctrl+Shift+Alt+M) to get the code required. Here is an example of the … Read more

How to Hide Added to Cart message in WooCommerce

Update for WooCommerce 3+ The hook wc_add_to_cart_message is deprecated and replaced by wc_add_to_cart_message_html. You can use the following (compact effective way): [php]add_filter( ‘wc_add_to_cart_message_html’, ‘__return_false’ );[/php] Or the normal way: [php]add_filter( ‘wc_add_to_cart_message_html’, ’empty_wc_add_to_cart_message’); function empty_wc_add_to_cart_message( $message, $products ) { return ”; }; [/php] Before WooCommerce 3, use this: Removing only the message (pasting it to your function.php file inside … Read more