How to set default values in Woocommerce checkout? [closed]

Try this code to change the default billing country on the checkout page. add_filter( ‘default_checkout_billing_country’, ‘change_default_checkout_country’ ); function change_default_checkout_country() { return ‘US’; // country code } To change default shipping country on the checkout page function change_set_checkout_field_input_value_default($fields) { $fields[‘shipping’][‘shipping_country’][‘default’] = ‘Australia’; return $fields; } add_filter( ‘woocommerce_checkout_fields’, ‘change_set_checkout_field_input_value_default’ );

How do I get the latest note on the order at woocommerce? [closed]

The order notes are saved as post comments, so you can use the WordPress function get_comments() to get the last note: $args = array( ‘post_id’ => $order_id, ‘orderby’ => ‘comment_ID’, ‘order’ => ‘DESC’, ‘approve’ => ‘approve’, ‘type’ => ‘order_note’, ‘number’ => 1 ); remove_filter( ‘comments_clauses’, array( ‘WC_Comments’, ‘exclude_order_comments’ ), 10, 1 ); $notes = get_comments( … Read more

Redirect the single product page link to the shop page

You can try using template_redirect action hook to check if the current page is product page and after that, you can redirect the user to your shop page. Paste this code into your functions.php add_action(‘template_redirect’,’custom_shop_page_redirect’); function custom_shop_page_redirect(){ if (class_exists(‘WooCommerce’)){ if(is_product()){ wp_redirect(home_url(‘/shop/’)); exit(); } } return; } I have not tested it, but hope it will … Read more

echo product id and product_item_key in cart [closed]

Techno Deviser, probably by mistake, in the foreach loop set value to $fragments[‘div.header-cart-count’] instead append it. Try this modification: function iconic_cart_count_fragments( $fragments ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $fragments[‘div.header-cart-count’] .= ‘<div class=”header-cart-count”>’ .$cart_item_key.'<br><br>’. $cart_item[‘product_id’]. ‘</div>’; } return $fragments; } Or: function iconic_cart_count_fragments( $fragments ) { $cart = WC()->cart->get_cart(); if (!empty($cart)) … Read more

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