Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter bimbaim

    (@bimbaim)

    Hello,

    This is sorting for the front page/shop page,

    First, I think something like using order by hooks but I can’t find how to use it with the product type! it only works for me if the product type is meta, not taxonomy.

    so I hope there is a way to sort by product type, especially by this sequence: grouped products, variable products, then simple products.

    Thanks

    • This reply was modified 4 years, 2 months ago by bimbaim.
    Thread Starter bimbaim

    (@bimbaim)

    ok thank you for supports. I will inform themes developer for future fix. Right now bug is fixed

    Thread Starter bimbaim

    (@bimbaim)

    After some try and error. Finally it solved.

    I still dunno what the issue but I check if the id of second product already in cart, if not put cart.

    That condition solve my issue.

     $found = false;
    if($product_ID){
          if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
    			foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
    				$_product = $values['data'];
    				if ( $_product->get_id() == $product_ID )
    					$found = true;
    			}
    			// if product not found, add it
    			if ( ! $found )
    				WC()->cart->add_to_cart( $product_ID );
    		} else {
    			// if no products in cart, add it
    			WC()->cart->add_to_cart( $product_ID );
    		}
    }
Viewing 3 replies - 1 through 3 (of 3 total)