Switch to user link

Here is tested code: add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘display_admin_switch_user’, 10, 1 ); function display_admin_switch_user($order){ $data = $order->get_data(); // The Order data $user = $order->get_user(); $user_id = $order->get_user_id(); if ( method_exists( ‘user_switching’, ‘maybe_switch_url’ ) ) { $url = user_switching::maybe_switch_url( $user ); if ( $url ) { printf( ‘<a href=”https://mysite.sk/plugins/user-switching/%1$s”>Switch to %2$s</a>’, esc_url( $url ), esc_html( $user->display_name ) ); … Read more

How to replace WooCommerce Product Gallery Trigger icon using PHP/CSS? [closed]

Its more of a hack than actual solution. But, I am using it in a lot of themes without any issues. .woocommerce div.product div.images .woocommerce-product-gallery__trigger { visibility: hidden; } .woocommerce div.product div.images .woocommerce-product-gallery__trigger::before { visibility: visible; } .woocommerce div.product div.images .woocommerce-product-gallery__trigger::after { visibility: visible; } Please note I have removed the my styling from these … Read more

How to set the meta description of a WooCommerce product as its primary category description?

Use the wpseo_metadesc filter: function wpse_406559_product_meta_description_from_category( $description ) { if ( ! is_singular( ‘product’ ) || $description ) { // Bail early if not single product, or custom meta description is already set return $description; } $product_cats = get_the_terms( get_queried_object_id(), ‘product_cat’ ); // Get first product category $product_cat = is_array( $product_cats ) ? current( $product_cats … Read more

A function to add arguments to a taxonomy

Use the filter register_taxonomy_args to manipulate the arguments used for registering the taxonomy just before it is registered: function wpse_406824_vendor_taxonomy_args( $args, $name ) { if ( $name === ‘dc_vendor_shop’ ) { $args[‘show_in_rest’] = true; $args[‘query_var’] = true; $args[‘show_ui’] = true; } return $args; } add_filter( ‘register_taxonomy_args’, ‘wpse_406824_vendor_taxonomy_args’, 10, 2 ); You’ll need to place this … Read more

Woocommerce check if email already created order recently [closed]

You can create a helper function for that which qurries the orders for given email and created less than 10 mins ago. function wpse407278_check_if_ordered_in_last_10_mins( $email ) { if ( !isset($email) || empty($email) ) { return false; } $args = array( ‘customer’ => $email, ‘date_created’ => ‘>’ . ( time() – strtotime(‘-10 minutes’) ), ); $orders … Read more

Remove ‘product’ & ‘product-cateogory’ from url – woocommerce [closed]

Found this neat little article on it, try this out! http://ryansechrest.com/2013/04/remove-post-type-slug-in-custom-post-type-url-and-move-subpages-to-website-root-in-wordpress/ It’s a guide/tutorial, so you should be able to get more information on what’s going on here if you visit his site. By the way, it’s against the rules to ask for a plugin here. add_action( ‘pre_get_posts’, ‘custom_pre_get_posts’ ); function custom_pre_get_posts($query) { global $wpdb; … Read more

Results not being printed

You’re _doing_it_wrong, as $product is an object. I’m pretty sure you want something like this: $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 4, ); $featured_query = new WP_Query($args); if ($featured_query->have_posts()) { while ($featured_query->have_posts()) { $featured_query->the_post(); ?> <h1 class=”post-title”><?php the_title(); ?></h1> <div class=”post-content”><?php the_content(); ?></div> <?php } wp_reset_postdata(); }