check for named meta data for a product.

shopp_product_has_meta ( $product, $name, $type )

@param int $product (required) the product id
@param string $name (required) the name of the meta entry
@param string $type (optional default: meta) the type of meta entry
@return bool returns true if meta data exists on the product, false if not


check for named meta data for a product.

This function uses shopp_meta().


// determine if product 15 has a meta entry with the name Author and type spec
if ( shopp_product_has_meta ( 15, 'Author', 'spec' ) ) {
$Author = shopp_product_meta( 15, 'Author', 'spec');

Shorthand method using ternary operators.

// This will set $Author to the meta key if it exists, or '' if not
$Author = (shopp_product_has_meta ( 15, 'Author', 'spec' ) ? shopp_product_meta( 15, 'Author', 'spec') : '');

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.