Product Variation Auto Select when only one 1 and mark the option [closed]

First, you need to ensure that your count($args[‘options’] is actually 1. Check the following example: You can see that when I print_r($args[‘options’]), I got 4 elements, so count($args[‘options’] here is 4. But if you look at the dropdown beneath it, you see that it only has 1 option. Why? Because variations (and their attributes) that … Read more

Add class to functions.php custom code to call font awesome icon

There’s no need to add another class. The code you’re using already creates separate classes and ID. You could do this with just css: Inspect your site with console, but your div label should be technical_documents so your code would be: #tab-title-technical_documents a::before { content: “\f02d”; font-family: ‘Font Awesome 6′; font-weight: 900; } You didn’t … Read more

Update a server-side render Block when woocommerce cart block changed

Something like this should work: const {select, subscribe} = window.wp.data; const cartStoreKey = window.wc.wcBlocksData.CART_STORE_KEY; const unsub = subscribe( onCartChange, cartStoreKey ); function onCartChange() { const cart = select( cartStoreKey ).getCartData(); console.log( ‘¡ cart change !’, cart ); } The block’s frontend script should have the woocommerce script’s handle as a dependency so the window.wc.wcBlocksData will … Read more

Modify existing code to show user nickname in woocoomerce order email instead of user_login

To show the users nickname in WooCommerce order emails instead of the user login, you need to retrieve the users display name from their user data. add_filter( ‘woocommerce_email_customer_details_fields’, ‘add_user_nickname_to_woocommerce_emails’, 10, 3 ); function add_user_nickname_to_woocommerce_emails( $fields, $sent_to_admin, $order ) { $user_id = $order->get_customer_id(); $user_info = get_userdata( $user_id ); // Retrieve the users nickname (display name) $user_nickname … Read more

WooCommerce: Custom dropdown for variation selection

I think the condition here has_term($term_slug, $taxonomy, $variation->get_id()) won’t work for variation. If you want to check term, we need to check with parent variable product instead of checking variation because Woocommerce doesn’t store any taxonomy/term attribute to variation. Instead of using has_term, we can use your existing attributes in get_variation_attributes to get and check … Read more

Custom Search Function in WordPress Returns No Results

Here’s the right code I made a mistake with s param function custom_search_query($query) { if (!is_admin() && $query->is_main_query() && $query->is_search()) { $search_query = get_search_query(); // Retrieve the search query $api_url=”https://api.adenwalla.in/api/search/data”; $args = array( ‘body’ => json_encode(array(‘query’ => $search_query)), ‘headers’ => array(‘Content-Type’ => ‘application/json’), ‘timeout’ => 60 ); $response = wp_remote_post($api_url, $args); $body = wp_remote_retrieve_body($response); $results … Read more

WooCommerce Webhook Action When a New Product Review was Submitted/Created

As we know WooCommerce product reviews are essentially WordPress comments with a specific comment_type. Firstly we hook into the Comment Submission and then we will check If the Comment is a WooCommerce Product Review and then we trigger our Custom Action. Could you please try to add this to your theme’s functions.php or in your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)