Questions about mp_var_name

I'm working on posting products from the front-end and I have a couple questions about the Product Variable Name.

1. If there is no variable for the product, do I need to include an mp_var_name or just a title.
2. If there are variables for the product, are they stored as array's ?

Any info about how to build a proper form for what I want to do is greatly appreciated. So far I've got the custom post_type form working... I just need to cover the variables now.

Thanks

  • DavidM

    Hi wecreateyou,

    I've been looking into this one as well, though it's taking a moment.

    The variations are stored in arrays from what I've seen in the gateway code and I do believe every product has at least one variation, which holds all the default data (which I think would answer your first question).

    As for creating a front-end form, I've not yet done something like that myself, so wouldn't really know, but I'd generally look at something like the front-end forms plugin to see how they do it and get an idea for how it could be done.

    I'll have to keep digging into the code on this, though I'm pretty sure the variations hold some of the product data you'd need, such as 'mp_price' for instance.

    Cheers,
    David

  • DavidM

    Hi wecreateyou,

    Sorry, I was a bit off earlier, the gateway section would be different from this.

    Instead, looking at line 1435 of template-functions.php for example, you can see the function is checking for variations, and if there's more than one, then it proceeds to list the variations and prices.

    //create select list if more than one variation
    if (is_array($meta["mp_price"]) && count($meta["mp_price"]) > 1 && empty($meta["mp_file"])) {

    So basically it's checking if this is an array, then counting the elements in the array, checking if it's more than 1 (meaning there are indeed variations) and also checking if this is a downloadable product.

    Not sure if you've already gotten that far but perhaps that'll help a bit in seeing how to detect if there are variations?

    Cheers,
    David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.