How can I integrate an image between the articles on the product overview page?
PHP <script> jQuery(document).ready(function() { jQuery ( function($) { jQuery(“.term .wd-product:nth-child(4)”).after(“<div class=’category-content-img’><img src=’images.jpg’></div>”); }); }); </script> CSS .category-content-img { width: 100%; grid-column-start: 1; grid-column-end: 5; } .category-content-img img { width: 100%; }
How can I display only products in the search results?
add_filter(‘pre_get_posts’,’lw_search_filter_pages’); function lw_search_filter_pages($query) { // Frontend search only if ( ! is_admin() && $query->is_search() ) { $query->set(‘post_type’, ‘product’); $query->set( ‘wc_query’, ‘product_query’ ); } return $query; }
How can i show only the cheapest shipping rate at checkout?
function my_only_show_cheapest_shipping_rate( $rates, $package ) { $cheapest_method = ”; // Loop through shipping rates if ( is_array( $rates ) ) : foreach ( $rates as $key => $rate ) : // Set variables when the rate is cheaper than the one saved if ( empty( $cheapest_method ) || $rate->cost < $cheapest_method->cost ) : $cheapest_method = […]
How can i replace zero cost to "Free" from shipping method label and email?
Label add_filter( ‘woocommerce_cart_shipping_method_full_label’, ‘Add_free_to_shipping_label_for_zero_cost’, 10, 2 ); function Add_free_to_shipping_label_for_zero_cost( $label, $method ) { // If shipping method cost is 0 or null, display ‘Free’ (except for free shipping method) if ( ! ( $method->cost > 0 ) && $method->method_id !== ‘free_shipping’ ) { $label .= ‘: ‘ . __(‘Free’); } return $label; } E-Mail add_filter( […]
How to remove product & product-category from urls?
To achieve this, two adjustments must be made. Under Settings > Permalinks, a point (.) must be entered under “Category base products”. In addition, add the following script to functions.php: add_filter(‘request’, function( $vars ) { global $wpdb; if( ! empty( $vars[‘pagename’] ) || ! empty( $vars[‘category_name’] ) || ! empty( $vars[‘name’] ) || ! empty( […]
How can I create an additional field for the house number?
Sometimes it is helpful if there is an extra field for the house number (the alternative is to check within the address field whether there is a number). There are two variants for an extra field: 1.) If the address field 2 is not used, you can activate it under Customize > WooCommerce > Checkout […]
How to add an optional VAT ID field to the checkout?
add_filter( ‘woocommerce_checkout_fields’ , ‘checkout_address_details_fields’ ); function checkout_address_details_fields( $fields ) { $fields[‘billing’][‘ct_invoice_taxid’] = array( ‘label’ => __(‘USt-Identifikationsnummer’, ‘woocommerce’), ‘placeholder’ => ”, ‘required’ => false, ‘class’ => array(‘form-row-wide’), ‘clear’ => true, ‘priority’ => 35, ); return $fields; } add_action( ‘woocommerce_checkout_update_order_meta’, ‘ct_invoice_save_fields’ ); function ct_invoice_save_fields( $order_id ) { if ( ! empty( $_POST[‘ct_invoice_taxid’] ) ) { update_post_meta( $order_id, […]
How do I add a custom WooCommerce quantity button?
add_action( ‘woocommerce_after_add_to_cart_quantity’, ‘ts_quantity_plus_sign’ ); function ts_quantity_plus_sign() { echo ‘<button type=”button” class=”plus” >+</button>’; } add_action( ‘woocommerce_before_add_to_cart_quantity’, ‘ts_quantity_minus_sign’ ); function ts_quantity_minus_sign() { echo ‘<button type=”button” class=”minus” >-</button>’; } add_action( ‘wp_footer’, ‘ts_quantity_plus_minus’ ); function ts_quantity_plus_minus() { if ( ! is_product() ) return; ?> <script type=”text/javascript”> jQuery(document).ready(function($){ $(‘form.cart’).on( ‘click’, ‘button.plus, button.minus’, function() { var qty = $( this ).closest( […]
What is the WooCommerce Thank You Page URL?
If nothing has been changed in the default settings or the paths within WooCommerce have been renamed, the path is: …/checkout/order-received/
How to add a custom class to the product loop using a custom field?
add_filter( ‘woocommerce_post_class’, ‘add_category_class’); function add_category_class( $classes ) { $custom_videoclass = get_post_meta(get_the_ID(), ‘produktvideoclass’, true); if ( ‘product’ == get_post_type() ) { $classes[] = $custom_videoclass; } return $classes; }