Advertisement
palsushobhan

vendor-featured-products-shortcode.php

Jun 24th, 2021
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. add_shortcode('wcfm_store_featured_products', function($attr) {
  2.     global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;    
  3.     $store_id = '';
  4.     if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }  
  5.     if (  wcfm_is_store_page() ) {
  6.         $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
  7.         $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
  8.         $store_id  = 0;
  9.         if ( !empty( $store_name ) ) {
  10.             $store_user = get_user_by( 'slug', $store_name );
  11.         }
  12.         $store_id = $store_user->ID;
  13.     }  
  14.     if( is_product() ) {
  15.         $store_id = $post->post_author;
  16.     }
  17.     if( !$store_id && is_single() && $post && is_object( $post ) && wcfm_is_vendor( $post->post_author ) ) {
  18.         $store_id = $post->post_author;
  19.     }
  20.  
  21.     if ( isset( $attr['limit'] ) && !empty( $attr['limit'] ) ) {
  22.         $limit = absint($attr['limit']);
  23.         echo do_shortcode('[products store="'.$store_id.'" visibility="featured" limit="'.$limit.'"]');
  24.     } else {
  25.         echo do_shortcode('[products store="'.$store_id.'" visibility="featured" ]');
  26.     }
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement