fauzanjeg

Jeg Font Preview - WooCommerce || Shortcode for JFP WooCommerce preview

Nov 9th, 2026
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. /**
  2.  * Shortcode for JFP WooCommerce preview.
  3.  *
  4.  * Usage: [jfp_wc_preview id="PRODUCT_ID"]
  5.  *
  6.  * @author Fauzan Edris
  7.  * @link https://www.linkedin.com/in/fauzanedris/
  8.  */
  9. add_shortcode( 'jfp_wc_preview', function( $atts ) {
  10.     $atts = shortcode_atts( array(
  11.         'id' => 0,
  12.     ), $atts );
  13.  
  14.     $product_id = (int) $atts['id'];
  15.  
  16.     if ( ! $product_id ) {
  17.         return 'Product ID is required.';
  18.     }
  19.  
  20.     if ( ! function_exists( 'jfp_woocommerce_preview_is_active' ) ) {
  21.         return 'The JFP WooCommerce plugin is not active.';
  22.     }
  23.  
  24.     if ( ! jfp_woocommerce_preview_is_active( $product_id ) ) {
  25.         return 'Preview is not enabled for this product.';
  26.     }
  27.  
  28.     $single = new \JFP_WOOCOMMERCE\Single\Single_Post();
  29.     return $single->render_preview( '', $product_id );
  30. });
Advertisement
Add Comment
Please, Sign In to add comment