WooCommerce related products load random posts per page

You need to change the value of $orderby. Maybe the current value of $orderby is rand ‘orderby’ => $orderby, Now you need to change the value of **orderby => ” ** according to your need. for example ‘orderby’ => ‘title’ ‘orderby’ => ‘menu_order title’ ‘orderby’ => ‘comment_count’ ‘orderby’ => ‘meta_value_num’ ‘orderby’ => ‘title menu_order’ Order … Read more

Replace “Add to cart” by a link to contact page on specific product

You can try this. I think it works fine. /*PUT THIS IN YOUR THEME FUNCTIONS FILE*/ /*STEP 1 – REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */ add_action(‘init’,’remove_loop_button’); function remove_loop_button(){ remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 ); } /*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */ add_action(‘woocommerce_after_shop_loop_item’,’replace_add_to_cart’); function replace_add_to_cart() … Read more

login or register then access woocommerce website

You can use “template_redirect” action to check if the current user is logged in or not then redirect the user to my-account page if not. add_action( ‘template_redirect’, function() { $url_parts = array_filter( explode( “https://wordpress.stackexchange.com/”, $_SERVER[‘REQUEST_URI’] ), ‘strlen’ ); if ( ! is_user_logged_in() && ( end( $url_parts ) != ‘my-account’ ) ) { wp_redirect( home_url( ‘/my-account’ … Read more

How to customize product at cart page

use this function and edit cart page template /** * Display engraving text in the cart. * * @param array $item_data * @param array $cart_item * * @return array */ function iconic_display_engraving_text_cart( $item_data, $cart_item ) { if ( empty( $cart_item[‘iconic-engraving’] ) ) { return $item_data; } $item_data[] = array( ‘key’ => __( ‘Engraving’, ‘iconic’ ), … Read more

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