Need to change product name when on mp category pages using gridmarket theme

Hello, I am using marketpress with framemarket/grindmarket. I want to change the name of the products on category pages (described better by my screenshot I hope), so I can use the category pages to define the products name and to use the links to the products listings to output the quantities instead of repeating the product name again. I am trying to avoid changing the actual page names of the individual products. Im guessing that I need to either change my category template or write an if statement to replace the name output when on category pages, but I dont know the best course of action or what I would need to select to replace the name using an if statement. Hope that wasn't too confusing.

  • PC
    • WPMU DEV Initiate

    Hello there Justin,

    Thanks for posting on the forums.

    To achieve that you will need to modify the category template page and use something like http://wordpress.org/plugins/get-custom-field-values/ to help you fetch the value of custom fields.

    http://codex.wordpress.org/Custom_Fields#Getting_Custom_Fields also explains how to get Custom fields value : http://codex.wordpress.org/Custom_Fields#Getting_Custom_Fields

    It will also include the modification in MarketPress template file for which I can get you the right help but that will include a core code change which is not update proof and you will need to do that everytime there is a plugin update as I am not sure if there is a filter for that. But if required we will look into this :slight_smile:

    However from what I see in your screenshot, you have the same product name with a slight difference right ? Why don't use simply use Product Variations feature in MarketPress ?

    It allows you to add a variation in a product so you can have multiple options under a single product such as :

    9 MM
    Variations : 100 pack / 1000 pack / etc.

    That will help you avoid making any core changes and achieve what you want with ease :slight_smile:

    I hope that helps. Please feel free to ask if you have more questions on the same.

    Cheers, PC

  • justin_andrews
    • Design Lord, Child of Thor

    Thank you for your response. Sounds like we are on the right track as far as the custom fields plugin. As far as using variations, I want to avoid this because we want individual pages for the quantities and to continue using the category pages to show the quantities. I admit I was a bit worried that I would have to make core changes, ideally I would like these changes to be unharmed by updating if possible but if that isn't an option then I can make do with reapplying with each update. I appreciate you finding me the right help.

  • PC
    • WPMU DEV Initiate

    Hey there Justin,

    Thanks for posting back.

    If its a core change, there is no update proof solution unless it can be done using the code as a separate plugin.

    I have called in our Second Level support so that they can dive in the code for you and see if there is any quick solution to this problem

    They should be around sooner than later.

    Cheers, PC

  • Patrick
    • Support Monkey

    Hi there @justin_andrews

    I hope you don't mind me jumping in here.

    I believe the function you would want to customize can be found in marketpress/marketpress-includes/template-functions.php.

    To my slightly-less-than-experienced coder's eyes, that would seem to be a pluggable function; meaning it should be possible to override it in a custom template.

    However, I just tried to but either I'm not doing it right, or my assumption is wrong. :slight_frown:

    I just flagged our 2nd-level support team again to get some more knowledgeable help in on this issue. Hang on...

  • justin_andrews
    • Design Lord, Child of Thor

    Thank you Patrick, that put me a step closer. In the screenshot you can see I dug in for a closer look and believe I isolated the code. But i'm not quite sure if it is and if indeed it is im not quite sure the best course of action to take to accomplish what I need. Hopefully those questions can be answered by the 2nd-level support team (where ever they may be) or someone more familiar with this than my self.

  • Hoang Ngo
    • Code Slayer

    Hi @justin_andrews,

    I hope you are well today.

    If you are using gridmarket template, so the function handler is "framemarket_grid_mp_list_products", at the file wp-content/themes/framemarket/library/functions/marketpress.php
    Please look at the line 121, you will see the code:
    $content .= '<h3 class="mp_product_name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';

    This is exactly the place you need to modify :slight_smile:.

    Sadly that the theme don't have any filter for this, so you will need to update in the core code. And please remember, it will gone when you update the theme.

    Best Regards,
    Hoang

    • justin_andrews
      • Design Lord, Child of Thor

      Thank you, I will certainly check that out as soon as I can and let ya'll know how I solved (hopefully it can help others scouring the web). I know this is a step that isn't often needed done in most store sites, but if a change could be added a little later to add a filter that would be cool. A little extra control can't hurt, but I understand it is a small point when the developers are understandably focusing on bigger issues and new features.

  • Hoang Ngo
    • Code Slayer

    Hi @justin_andrews,

    Please give it a try and let us update :slight_smile:.

    I do agree with you about the extra hook/filter, this will make everything easier and cleaner.

    I'm going to notice the developer, so he can consider applying this for the future release.

    Best Regards,
    Hoang

  • justin_andrews
    • Design Lord, Child of Thor

    Big thanks to Hoang for pointing me in the right direction, in wp-content/themes/framemarket/library/functions/marketpress.php right around line 122 you should see this: $content .= '<h3 class="mp_product_name"><a href="' . get_permalink( $post->ID ) . '">' $post->post_title') . '</a></h3>'; which is simply the HTML output for the product name in "framemarket_grid_mp_list_products". So I installed CustomPress, made a custom field and replaced $post->post_title with my custom fields shortcode function . do_shortcode('[ct id="ID-Given-By-CustomPress"] but keep in mind updates will undo this change so you will have to make these changes after every update to framemarket; until a filter/hook is added. Hope this helps.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.