• Resolved natelvl

    (@natelvl)


    Hi suport,

    I need to display the SKU when I’m adding a simple product to the bundle product. Because I have the same products but the only difference is the SKU, so when I add a simple product i need to know that, I have chosen the right product.
    And i know that I can search a product with the SKU but I need this function for efficiency.
    For instance I would like to have the same function that I implemented in order list item :

    add_action( 'woocommerce_thankyou', 'order_created_get_skus', 10 );
    
    function order_created_get_skus($order_id){
    
      $item_sku = array();
      $order = wc_get_order( $order_id ); 
    
      foreach ($order->get_items() as $item) {
        $product = wc_get_product($item->get_product_id());
        $item_sku[] = $product->get_sku();
      }
    
    }

    Thanks for your answer,

    Kind regards.

    • This topic was modified 3 years, 3 months ago by natelvl.
    • This topic was modified 3 years, 3 months ago by natelvl.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WPClever

    (@wpclever)

    Hi @natelvl

    Where do you want to display the product SKU, on the search result https://www.screencast.com/t/CKRZ1LIU0 or the single product page https://www.screencast.com/t/qXT0eqqqA?

    Thread Starter natelvl

    (@natelvl)

    Hi,

    I need to display the product SKU on the search result https://www.screencast.com/t/CKRZ1LIU0, thus i can choose the right simple product to add on the product bundle,
    I have another issue, when I want to remove the product bundle of an order in the item list, it’s only removing the product bundle and not all the product inside. How can I do to remove all the product when I remove the product bundle ?

    Thanks

    • This reply was modified 3 years, 3 months ago by natelvl.
    Plugin Author WPClever

    (@wpclever)

    #1. About SKU:

    Please update our plugin to the latest version 6.0.4 then add below snippet:

    add_filter( 'woosb_item_product_info', 'woosb_item_product_info_with_sku', 99, 2 );
    function woosb_item_product_info_with_sku( $info, $product ) {
    	if ( $sku = $product->get_sku() ) {
    		$info .= ' | ' . $sku;
    	}
    
    	return $info;
    }

    And the result https://www.screencast.com/t/dMVcudsV61i

    #2. About removing the bundle:

    Currently, WooCommerce hasn’t an action hook at this position, so we can’t write the function for this task and we need to remove bundled products manually.

    Thread Starter natelvl

    (@natelvl)

    Hi,

    It works thanks for the support

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘display SKU on product bundle’ is closed to new replies.