• livedub

    (@livedub)


    code-snippets/php/snippet-ops.php(446) : eval()’d code
    on line 5

    line 5 is : if(!empty($terms))

    above error need help thanks

    my partly code

    $terms = get_the_terms( $product->get_id(), ‘product_cat’ );
    $product_categrories = array();
    if(!empty($terms))
    { foreach ($terms as $term) {
    $product_categrories[] = $term->name;

    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Can you give me some more information? What’s the error message? What is this code trying to do?

    Thread Starter livedub

    (@livedub)

    hi Shea i’m trying to make category product only available on some days

    function enable_product_specific_days( $purchasable, $product ){

    $terms = get_the_terms( $product->get_id(), ‘product_cat’ );
    $product_categrories = array();
    if(!empty($terms))
    { foreach ($terms as $term) {
    $product_categrories[] = $term->name;

    }

    }

    if(in_array(“GRATITUDE MENU”, $product_categrories) )
    {
    if(date(‘l’) ==”Tuesday” ||date(‘l’) ==”Wednesday” )
    {
    return true;
    }
    else
    {
    return false;

    }

    }
    else
    {
    return true;

    }

    return true;
    }
    add_filter( ‘woocommerce_is_purchasable’, ‘enable_product_specific_days’, 10, 2 );

    Plugin Author Shea Bunge

    (@bungeshea)

    What error message do you receive?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP ERRORS’ is closed to new replies.