0, ), $atts, 'studiou_free_photo_product'); $product_id = absint($atts['id']); if (!$product_id) { return '
' . esc_html__('Product ID is required.', 'studiou-wc-free-photo-product') . '
'; } $product = wc_get_product($product_id); if (!$product) { return '' . esc_html__('Product not found.', 'studiou-wc-free-photo-product') . '
'; } if (!Studiou_WC_FPP_Product::is_fpp_product($product_id)) { return '' . esc_html__('This product does not support photo upload.', 'studiou-wc-free-photo-product') . '
'; } if (!$product->is_type('variable')) { return '' . esc_html__('This product must be a variable product.', 'studiou-wc-free-photo-product') . '
'; } // Enqueue assets wp_enqueue_style('studiou-wcfpp-frontend'); wp_enqueue_script('studiou-wcfpp-frontend'); $max_file_size = Studiou_WC_FPP_Product::get_product_max_file_size($product_id); // Set global product so WC template functions work global $post; $original_post = $post; $post = get_post($product_id); setup_postdata($post); ob_start(); include STUDIOU_WCFPP_PLUGIN_DIR . 'views/frontend-product.php'; $output = ob_get_clean(); // Restore original post $post = $original_post; if ($original_post) { setup_postdata($original_post); } else { wp_reset_postdata(); } return $output; } }