• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2787

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Checkout
  • Cart
  • Videos

Conditionally Show Hide Custom WooCommerce Checkout Fields Based on Cart Weight

$75.00

Demo Video
Category: WooCommerce Tags: Custom Fields, get_cart_contents_weight, woocommerce_billing_fields, woocommerce_checkout_fields
  • Description

Both code snippets in this download folder enable you to show a specific custom field based on the total weight of all products in the cart on the WooCommerce checkout page.

  • By default, the code is written to show a custom field named Up To 500 kg when the weight is 500 kg or less. Other fields will not display.
  • When the weight is over 500 kg or less than 1001 kg a field named Over 500kg & Less Than 1001kg displays and all other fields are hidden.
  • When the total weight in the cart is more than 1000 kg, a field named Over 1000 kg is shown and all other fields are hidden.

The custom field value is output on the WooCommerce > Orders > Edit Order screen like this under the shipping details :

Installation

Copy & paste the PHP code from the functions.php or functions 2.php file to the end of your child themes functions file or custom functionality plugin.

Primary Sidebar

Cart

Code written by Brad Dalton specialist for WooCommerce with more than 10 years of experience.

Advertise · WPEngine · Genesis · Log in

  • Code Snippets
  • Tutorials
  • Videos
  • Account
  • Checkout
  • Cart
 

Loading Comments...
 

You must be logged in to post a comment.