Skip to content

Instantly share code, notes, and snippets.

@marrisonlab
marrisonlab / gist:2d2b1e2423312076256e9def70ff931a
Created September 27, 2025 06:33
Display Dokan Vendor meta in single product page and loop
/**
* Snippet unificato Dokan + Vendor
* Funziona sia con ID utente generico che con loop prodotto
* WPCode: PHP Snippet → Run Everywhere
*/
if ( ! function_exists( 'sn_get_product_from_context' ) ) {
function sn_get_product_from_context() {
global $product;
if ( isset( $product ) && is_object( $product ) ) return $product;
@marrisonlab
marrisonlab / gist:b02883c4a594ca733aedd3ce88406443
Created September 27, 2025 06:29
Display brand in single product page (woo)
function gl_brand_logo_shortcode( $atts ) {
if ( is_admin() ) return '';
$atts = shortcode_atts([
'size' => 'medium', // thumbnail|medium|large|full o 300x150
'class' => 'brand-logo',
'link' => 'yes', // yes|no
'tax' => '' // lascia vuoto per auto-rilevare
], $atts, 'brand_logo');
@marrisonlab
marrisonlab / gist:6183d08d62a3cd9496f1ccb0006bc4b9
Created September 26, 2025 16:06
Discount % in Jetengine product listing
add_shortcode( 'sale_percentage', function( $atts ) {
$atts = shortcode_atts( array(
'id' => get_the_ID(),
), $atts, 'sale_percentage' );
$product = wc_get_product( $atts['id'] );
if ( ! $product ) return '';
$max_percentage = 0;