Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Shortcode for JFP WooCommerce preview.
- *
- * Usage: [jfp_wc_preview id="PRODUCT_ID"]
- *
- * @author Fauzan Edris
- * @link https://www.linkedin.com/in/fauzanedris/
- */
- add_shortcode( 'jfp_wc_preview', function( $atts ) {
- $atts = shortcode_atts( array(
- 'id' => 0,
- ), $atts );
- $product_id = (int) $atts['id'];
- if ( ! $product_id ) {
- return 'Product ID is required.';
- }
- if ( ! function_exists( 'jfp_woocommerce_preview_is_active' ) ) {
- return 'The JFP WooCommerce plugin is not active.';
- }
- if ( ! jfp_woocommerce_preview_is_active( $product_id ) ) {
- return 'Preview is not enabled for this product.';
- }
- $single = new \JFP_WOOCOMMERCE\Single\Single_Post();
- return $single->render_preview( '', $product_id );
- });
Advertisement
Add Comment
Please, Sign In to add comment