How to reverse/swap the order of “Sales price” and “Regular prcie” in woocommerce?

You’re going to want to use hooks and filters to change that. I would look at the woocommerce_get_price_html and/or woocommerce_variable_price_html filters. EDIT: here is the core WC code you need to alter: /** * Format a sale price for display. * * @since 3.0.0 * @param string $regular_price Regular price. * @param string $sale_price Sale … Read more

How can I compel alphanumeric entries for username textbox on woocommerce registration form

You can use the woocommerce_registration_errors hook to validate the username & set an error if your conditions aren’t met – WooCommerce will bail and pass the error back to the UI for the user: add_filter( ‘woocommerce_registration_errors’, function ( WP_Error $errors, $username ) { if ( ! preg_match( ‘/[a-z]/i’, $username ) ) { $errors->add( ‘username’, ‘Username … Read more

How it it possible to disbale all WooCommerce scripts and styles, but keep wc-ajax=get_refreshed_fragments working? [closed]

If you look how that script is loaded in WC core ‘wc-cart-fragments’ => array( ‘src’ => self::get_asset_url( ‘assets/js/frontend/cart-fragments’ . $suffix . ‘.js’ ), ‘deps’ => array( ‘jquery’, ‘js-cookie’ ), ‘version’ => WC_VERSION, ), You’ll see the path to that script, as well as it’s dependencies. rebuild that path and enqueue it yourself. FYI $suffix is … Read more

Hide prices from certain category in woocommerce

The is_category() method checks whether the current query is for an existing category archive page. Being woocommerce you should use the is_product_category() method instead, and to check for single product the has_term($slug, ‘product_cat’, $product_id) method. This code will remove prices from archive pages and single product pages: add_action( ‘woocommerce_after_shop_loop_item_title’, ‘hide_loop_product_prices’, 1 ); function hide_loop_product_prices(){ global … Read more

How can I reference external attachments without breaking core WordPress files?

Pay attention to the comments along the snippet. <?php /** * Filters the attachment URL. * * @param string $url URL for the given attachment. * @param int $att_id Attachment post ID. * * @return string $url Custom URL for the given attachment. */ function wp_get_attachment_url_callback( $url, $att_id ) { // Instead of keeping full … Read more