Woocommerce – Problem sorting and filtering products with different tax rates by price [closed]

Wasn’t able to find any solution to my problem so I made a simple plugin: <?php /** * Plugin Name: calisia-sort-and-filter * Author: Tomasz Boroń */ //order by; add new options and remove defaults add_filter( ‘woocommerce_default_catalog_orderby_options’, ‘calisia_sort_and_filter::add_new_postmeta_orderby’ ); add_filter( ‘woocommerce_catalog_orderby’, ‘calisia_sort_and_filter::add_new_postmeta_orderby’ ); //order by; arguments add_filter( ‘woocommerce_get_catalog_ordering_args’, ‘calisia_sort_and_filter::add_postmeta_ordering_args’ ); //price filtering add_action(‘woocommerce_product_query’, ‘calisia_sort_and_filter::min_max_price_handler’); //save meta … Read more

Unable to pull in custom product attribute in shortcode [closed]

In case anyone needs it, here was my final code: <?php //LIST ALL DOCUMENTS add_shortcode(‘listDocs’,’listDocs’); function listDocs(){ $params = array( ‘paged’ => get_query_var(‘paged’, 1), ‘posts_per_page’ => 25, ‘post_type’ => ‘product’, ‘product_cat’ => ‘documents’ ); $wc_query = new WP_Query($params); while ($wc_query->have_posts()) { $wc_query->the_post(); $product_id = get_the_ID(); $product = wc_get_product($product_id); $author = $product->get_attribute(‘written-by’); $date = get_the_date(‘F Y’, … Read more

Remove WooCommerce block styles

The dequeue handle is incorrect it should be wp_dequeue_style(‘wc-block-style’); and not wp_dequeue_style(‘wc-block-style-css’); A bit confusing at first i agree, every js and css that was enqued via wp_enqueue_style or wp_enqueue_script gets a suffix of css/js Example wp_enqueue_style(‘swiper’, ‘https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.4.6/css/swiper.min.css’) This will create a <link> with an id attribute of swiper-css, im guessing this is why you … Read more

Woocommerce. Max weight per order based on shipping class

This will do it: add_action(‘woocommerce_check_cart_items’,’check_cart_weight’); add_action(‘woocommerce_checkout_process’, ‘check_cart_weight’ ); function check_cart_weight() { $cart = WC()->cart; if(!$cart) return; $weight = 0; foreach($cart->get_cart_contents() as $item) { if(!isset($item[‘product_id’])) continue; $prod = wc_get_product($item[‘product_id’]); if($prod->get_shipping_class()!==’sypkie’) continue; $weight += ($item[‘quantity’] * (float)$prod->get_weight()); }; if( $weight > 125 ) { $error = sprintf( __( ‘You have %sKg weight and we allow only 125Kg … Read more