Support » Plugin: Woo Product Table - Free WooCommerce Table view solution » Select products sku in shortcode

  • Resolved gustavu92

    (@gustavu92)


    Hello, it is possible to select the products by sku in the shortcode?
    For example: [Product_Table id=’123′ skus=’sku1, sku2, sku3′]

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Saiful Islam

    (@codersaiful)

    for that, u have to customize using filter hook.
    Check hook list.

    Thread Starter gustavu92

    (@gustavu92)

    Sorry, I could not find it in the documentation. Can you point where can I find it? Or even give some example about this feature? This feature can be used only in the premium version?

    Plugin Author CodeAstrology IT Firm

    (@codeastrology)

    Check this one https://wooproducttable.com/plugin-api/wpto_table_query_args/

    Hope you can understand how to use this filter for your attributes

    Plugin Author Saiful Islam

    (@codersaiful)

    Following Script can help you.

    if( !function_exists( 'ultraaddons_arg_manipulation' ) ){
        
        /**
         * Getting SKU by shortcode Attribute
         * and I have explode skus by explode and
         * find out product id
         * and finally I make a array of product ids
         * 
         * @param type $args
         * @param type $table_ID
         * @param type $atts
         * @return Array
         */
        function ultraaddons_arg_manipulation( $args, $table_ID, $atts ) {
           
           //var_dump($args, $table_ID, $atts);
           $skus = $atts['skus'];
           $skus = explode(',', $skus);
           if( is_array( $skus ) ){
                $prds = array();
                foreach( $skus as $sku ){
                    $prds[] = wc_get_product_id_by_sku( $sku );
                }
                $args['post__in'] = $prds;
           }
           
           return $args;
       }
    }
    add_filter( 'wpto_table_query_args', 'ultraaddons_arg_manipulation', 10, 3 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.