Is there an easy way to add custom fields to marketpress?

Ok so I've installed Marketpress and Custompress - and I don't see a way to easily show the custom fields on the front end of the site. I'm trying to use MarketPress to present a client's Truck inventory. Is there an easy way to do this without having to add things to templates? The reason is that the client might add a custom field here and there to a product and I don't want them to have to call me every time they add one...

Thanks in advance!
Chris

  • Timothy Bowers

    Hey there.

    If you're wanting to target specific placement then it's going to require some theme editing.

    MarketPress is a custom post type, as such you could look to add custom fields through something like CustomPress:

    https://premium.wpmudev.org/project/custompress/

    CustomPress does provide embed codes for easy, specific implementation within a theme.

    I hope this helps.

    Take care.

  • Timothy Bowers

    Hey again.

    For the embeds, there are three options.

    You can either use a block (shortcode), so that it pulls all the information in one go (no template edits for your clients) or you embed that block within the theme code. If they add more fields, it will continue to come through the block, so no more code edits for your client.

    The third is that you can also embed individual fields where you wish, rather than pulling them all in one spot. If they add more fields, they will need to edit the code with this option.

    Embed codes are used in templates to return the value of the custom fields of the current post. Codes may be for individual fields using the Embed code links below for each field
    or you can display the entire block of custom fields for a listing using the embed code:
    <?php echo do_shortcode('[custom_fields_block]'); ?>

    Shortcodes are used in post, pages and widgets to return the value of the custom fields of the current post. Use inside the loop in Posts and Widgets
    [custom_fields_block]

    Take care.

  • chris_hunter

    Ok - I see. So I tested the shortcode and that worked.

    For others trying to figure this out here are the exact steps I took:

    1. Installed CustomPress (after MarketPress of course).
    2. Added Custom Fields and applied them to the "product" Post Type. I added Make, Model, Year, Mileage, etc.
    3. Create New product In the Products area and filled out pertinent info.
    4. Added following code inside of the description area:
    [custom_fields_block]

    This added an unordered list that looks like I can style in my template's stylesheet. Cool - but clunky and tons of room for the client to mess up/forget to add to each description area.

    So - next question is, if I wanted to add this to a template to make it less clunky with less room for the client to mess up:

    1. Where do I add the php code above?
    2. What template file, etc?
    3. Do I create a new custom php file? If so - where?

    Right now - this is just on a test site with default Twenty Twelve on it now, but my client's templates will be different and more custom.

    BTW - if there's documentation for this that outlines all of the above, please send me there. I just couldn't find it anywhere. :wink:

    Side note for developers: My suggestion for future versions of MarketPress would be to add ability to add Custom Fields without having to edit templates or even add CustomPress by the way (or add shortcode to each product). I'm coming from Joomla world to WP world and almost everything can be done with Virtuemart within the component itself. This seems like the best way to do it to me instead of having to edit templates. If you add custom fields and attach it to a post type - it should show up if it's populated.

    Additional thing I can't seem to find is how to add multiple images to a product. This seems like a pretty basic thing to do.

    This plugin seems very limited to me as it stands right now. (Just my two cents).

  • Timothy Bowers

    This added an unordered list that looks like I can style in my template's stylesheet. Cool - but clunky and tons of room for the client to mess up/forget to add to each description area.

    If we guessed the styling, then it probably wouldn't fit with all themes. For that reason the CSS is left to the site developer.

    So - next question is, if I wanted to add this to a template to make it less clunky with less room for the client to mess up:

    1. Where do I add the php code above?
    2. What template file, etc?
    3. Do I create a new custom php file? If so - where?

    The answer is, wherever you want it to appear.

    I don't know which theme you're using, where in the theme it should go, how you want it to render.

    If you wanted it in the side bar, and your theme only has one sidebar file, then you'd target that.

    Or you might have setup some custom template for for the product post type, if that's the case, then you'll probably want to target that.

    Or the theme might just use index.php or something else, and if that's the case then you'll want to target that.

    It will vary from theme to theme.

    If it's in a template that serves up other content and other post types you'll probably want to ensure it any container divs, or such only appear for that specific post type and if this is the case then you could encapsulate it with something like:

    if ( 'product' == get_post_type() ){
    CODE BLOCK FOR THE CUSTOM FIELDS
    }

    For Twenty Twelve you might target sidebar.php or single.php

    Or you might create your own template, MarketPress has a text file about that:

    /marketpress/marketpress-includes/themes/Themeing_MarketPress.txt

    As you see there, you can create a custom template for MarketPress. That way the code is specific to MarketPress pages.

    Additional thing I can't seem to find is how to add multiple images to a product. This seems like a pretty basic thing to do.

    It is, WordPress has a feature called the media library, this allows you to upload multiple images and embed them in the product listing.

    There are also plugins to make galleries different, or create different types of lightboxes.

    http://codex.wordpress.org/Media_Library_Screen

    The Library is available on the product creation screen. So, you can upload and embed at without leaving the product page.

    Cheers.

  • chris_hunter

    Timothy - thank for the help thus far.

    If we guessed the styling, then it probably wouldn't fit with all themes. For that reason the CSS is left to the site developer.

    I was actually saying that having somebody place shortcode in a description might lead to issues -- nothing about CSS. I agree that should be up to the site developer.

    Or you might create your own template, MarketPress has a text file about that:

    /marketpress/marketpress-includes/themes/Themeing_MarketPress.txt

    Is this the only documention for MarketPress? I cannot find documentation anywhere obvious.

    It is, WordPress has a feature called the media library, this allows you to upload multiple images and embed them in the product listing.

    I agree and understand this personally as a very advanced user of WordPress (installed/ configured/ themed over 450 websites personally).

    However handing this over to a client that needs a form to upload a set of images to -- this doesn't work. Clients just want to click a button and upload images. Multiple images in an ecommerce plugin (especially a paid one), should be included. Same with custom fields.

    Again, I would like to note that it would be much much better to add these few things. I've installed and played with "Directory" and it allows to custom fields out of the box. Meaning that you add a custom field and it actually shows up with the listing. There's no theme manipulation or shortcodes needed. Why can't this happen with MarketPress?

  • Timothy Bowers

    Hey again.

    Is this the only documention for MarketPress? I cannot find documentation anywhere obvious.

    With regards to theme, yes.

    MarketPress is a custom post type, and so the the WordPress codex can offer you insight into the WP code side.

    There is another file which can be of help:

    /marketpress/marketpress-includes/template-functions.php

    This is a bunch of functions you can use within your theme. Inline documentation there as well.

    You could also take a look at Frame/GridMarket to see what we've done in that theme:

    https://premium.wpmudev.org/project/frame-market-theme/

    Meaning that you add a custom field and it actually shows up with the listing. There's no theme manipulation or shortcodes needed. Why can't this happen with MarketPress?

    I'd have to double check on this and as such I've pinged our developer @Arnold he maintains CustomPress and should be able to offer further insight here.

    Take care.