Home / eCommerce / WC Vendors – Show the “AI” overlay on the product image
Duplicate Snippet

Embed Snippet on Your Site

WC Vendors – Show the “AI” overlay on the product image

Code Preview
php
<?php
// Add an "AI used" checkbox to the vendor's own product edit form, after Tax Class (General tab)
add_action( 'wcv_product_options_tax', function( $post_id ) {
    \WC_Vendors\Classes\Front\WCV_Form_Helper::input( array(
        'id'      => '_wcv_ai_generated',
        'post_id' => $post_id,
        'type'    => 'checkbox',
        'label'   => __( 'This product was created or modified using AI — show an "AI" tag on the storefront', 'wcvendors-pro' ),
        'cbvalue' => 'yes',
    ) );
} );
// Save the vendor's choice when they save the product
add_action( 'wcv_save_product', function( $product_id ) {
    update_post_meta( $product_id, '_wcv_ai_generated', isset( $_POST['_wcv_ai_generated'] ) ? 'yes' : 'no' );
} );
// Show the "AI" overlay on the product image (shop loop + single product page)
add_action( 'woocommerce_before_shop_loop_item_title', 'wcv_ai_tag_overlay', 9 );
add_action( 'woocommerce_before_single_product_summary', 'wcv_ai_tag_overlay', 9 );
function wcv_ai_tag_overlay() {
    global $product;
    if ( ! $product || 'yes' !== get_post_meta( $product->get_id(), '_wcv_ai_generated', true ) ) {
        return;
    }
    echo '<span style="position:absolute;top:0;left:0;z-index:9;background:#333;color:#fff;font-size:11px;padding:2px 8px;border-radius:0 0 4px 0;">AI</span>';
}

Comments

Add a Comment