Grow your CSS skills. Land your dream job.

WordPress + Foxycart

  • # September 11, 2009 at 1:55 pm

    OK, here’s another question for you guys:

    I’m, basically, trying to combine these two bits of code:

    Code:
    < ?php
    $productSize = get_post_meta($post->ID, “product-size”, false);
    if(!empty($productSize)) {
    print ‘‘;
    print ‘‘;
    print ‘

    ‘;
    }
    ?>

    and

    Code:
    < ?php
    $allOptions = get_post_meta($post=>ID, ‘dropdown-product-option’, false);
    if ($allOptions) {
    echo “;
    foreach ($allOptions as $option) {
    $fullValue = explode(“|”, $option);
    $optionName = $fullValue[0];
    $optionName = $fullValue[1];
    echo ““; }
    echo ““;
    } else {
    echo “

    $productCode   $$price

    “;
    }}
    ?>

    The second one may be familiar, since Chris used it (assuming I typed it correctly) in one of his screencasts.

    What I need to do is have the size of the product affect the price of the product. And I would like to do it the same way that Chris did: using a | to delineate the second part of the custom field and the php splitting the custom field at that marker and sending the second half as a option modifier that raises (or lowers) the price.

    My custom fields are labeled according to the first set of code.

    Does any of this make sense to anyone?

    Can anyone help?

    # September 11, 2009 at 4:04 pm

    OK, I’ve banged my head against the wall a few hundred times and I came up with this:

    Code:

    < ?php
    $productSize = get_post_meta($post->ID, “product-size”, false);
    if(!empty($productSize)) {
    print ‘‘;
    print ‘‘;
    print ‘

    ‘;
    }
    ?>

    It seems to work. Can anyone with more php knowledge than I have (not hard that) verify that it seems correct to them?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".