How to show store info & banner on single product page?

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 1 reply thread
  • Author
    Posts
    • #92465
      hahaha1132000
      Participant

      Hi guys, would like to know how we add shortcode to single product page? I tried using code below but nothing appear
      add_action( ‘woocommerce_before_single_product’, ‘wc_print_storeinfo’, 10 );
      function wc_print_storeinfo() {
      echo do_shortcode( ‘[wcfm_store_info id=”” data=””]’ );
      }
      Please help for this, thanks

      Attachments:
      You must be logged in to view attached files.
    • #92933
      Sushobhan
      Keymaster

      Hello,
      The code you are using is fine. All you need is to specify attributes of the shortcode, id and data. Now as per the documentation if you use this shortcode in store sidebar then it will automatically get current store id and you may just leave this parameter, which is not the case here. You are using this in single product page. So here you need to specify the vendor id. In data attribute you can use any of the following types –
      store_name, store_url, store_address, store_email, store_phone, store_gravatar, store_banner, store_support, store_social, store_location, store_rating

      Take a look at the modified code snippet-

      add_action( 'woocommerce_before_single_product', 'wc_print_storeinfo', 10 );
      
      function wc_print_storeinfo() {
          global $product, $WCFM;
          $id = $product->get_id();
          $vendor_id = $WCFM->wcfm_vendor_support->wcfm_get_vendor_id_from_product( $id );
          echo do_shortcode( "[wcfm_store_info id='".$vendor_id."' data='store_email']" );
      }

      Thanks

Viewing 1 reply thread
  • The topic ‘How to show store info & banner on single product page?’ is closed to new replies.