Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode('wcfm_store_products', function($attr) {
- global $post;
- $product_id = '';
- $store_id = '';
- if ( is_product() && $post && is_object($post) ) {
- $product_id = $post->ID;
- $store_id = $post->post_author;
- }
- if(! $store_id || ! $product_id ) return '';
- if ( isset( $attr['limit'] ) && !empty( $attr['limit'] ) ) {
- $limit = absint($attr['limit']);
- echo do_shortcode('[products store="'.$store_id.'" limit="'.$limit.'"]');
- } else {
- echo do_shortcode('[products store="'.$store_id.'"]');
- }
- });
- add_filter('woocommerce_shortcode_products_query', function ($query_args, $atts, $loop) {
- global $post;
- if ( is_product() && $post && is_object($post) ) {
- $product_id = $post->ID;
- $store_id = $post->post_author;
- }
- if(! $store_id || ! $product_id ) return '';
- $query_args['post__not_in'] = (array)$product_id;
- return $query_args;
- }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement