Marketpress Product list customisation

Firstly, apologies for the long list of questions! Trying to get my head around things which seem a little beyond my level and hoping someone can get me started.

I have installed Marketpress at www.milkchic.co.uk">httpwww.milkchic.co.uk but am not using it on my main shop pages yet. You can see what I have at the moment on my current shop pages It's an embedded Zoho database which I'm not 100% happy with (not least because it has no SEO value despite all my hard work!). The section I am playing around with is at http://www.milkchic.co.uk/store/view-all and is a mix of internal and external product lines.

My current plan is to create a formatted product list similar to the current one but with proper pagination etc. using Marketpress and place it on each page using shortcodes. I know this means duplicated content, so I may have to use canonical tags etc, but I'm not sure how easy it will be to filter dynamically, and I'd rather prioritise customer functionality over Google for now. The only thing this would be missing compared to current shop pages is a secondary filter / reorder by price etc. which I'll have to sort out later.

I also want to change the product list so it shows full product description not excerpt as I don't want the more info link to show.

My problem is that I can't get my head around theming. I've read all the documentation and lots of support posts and I have a css file which creates my custom theme, but I don't know how to edit my default page.php to make it into an mp_productlist.php. At the moment I can't even get it to work calling the existing formatting into my file so I'm obviously doing something badly wrong, and I have no idea which parts of the function code to use in order to edit the layout and content. I've tried looking at the Framemarket/Gridmarket files but they seem far removed from my page.php and I don't want a grid layout.

On the bright side, Custompress works like a dream for adding custom data to products, and if you are trying to make the "More Info" button on variations show with the same "Add to Cart" or "Buy it Now" button as external products, I've discoverd you just need to add your product page permalink in the external link box. It doesn't fix the price not showing issue, but looks a lot neater to my mind.

Final query (for today...) the automaticaly generated external links seem to be set as "dofollow"? Is there an easy way to change this as I don't want to dofollow any paid links?

    aecnu

    Greetings sequin,

    Final query (for today...) the automaticaly generated external links seem to be set as "dofollow"? Is there an easy way to change this as I don't want to dofollow any paid links?

    Not that I am aware of there is no easy way to do this but if I understand correctly you want to do this just for product external links?

    This may be achievable by modifying just the coding that is relative to external links.

    Please advise if I am on the right track.

    Thank you for being a WPMU Dev Member!

    Cheers, Joe

    ThePath

    Hi sequin, thanks for being a member and for using the forum!

    OK seems like you are a little overwhelmed, deep breath, ahhhhhh.

    Right you said:

    My problem is that I can't get my head around theming.

    Thats cool, its not for everyone but if its truly the case then I advise getting a professional to do it. Remember your time costs money to and could be better spent in other areas of the biz. Hiring a pro will save you time, effort and stop you pulling your hair out

    However I will point you in the right direction for getting products to show on your page.php template file. Try this:

    <div class="entry-content">
    		<div id="prodimage">
    		<?php if ( has_post_thumbnail() ) {
            	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
    			echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
    			the_post_thumbnail('medium');
    			echo '</a>';
             } ?>
             <?php  $id = get_post_thumbnail_id(get_the_ID()); // gets the post thumbnail ID ?>
                 </div>
            <div id="proddesc">
    			<?php
    				the_content();
    				mp_product_price();
    				mp_buy_button(true, 'single');
    			?>
            </div>
    	</div><!-- .entry-content -->

    So it depends on what theme you are using so the entry-content div might be called something else in your theme etc. And you would need to style the prodimage div also. But you should get the idea. If you add this code to your page.php you will see the product but you should probably be creating a mp_product.php file to do this for you, this is detailed in the themeing readme file.

    Actually I just had a peek at your website and you seem to have it working, can you confirm?

    sequin

    ommmmm! Just big ideas and not developing the skill to crack coding nearly quick enough Can't afford a pro yet, and I hate not being able to learn something.

    Thanks for coming back so quickly. The current store page is just using my page.php file. Every time I load the custom productlist it breaks! Will have a go with your code as that makes sense to me. If I can get that working, I think I can run with that - thank you.

    Re. the dofollow/nofollow, it's just external links I want to nofollow as they are largely affiliate links and I don't want to harm my Google page ranking. Might be something worth adding as an option in the next update, as it seems to be quite a major issue for sites with lots of affiliate links.

    Will go play with that code and come back to you - cheers!

    ThePath

    Hi Sequin, sorry I was offline for a day and lost track of this thread, hope you are making progress!

    Hey dont stress about it not sinking in, you will be surprised how much actually is going in. It take me a while to get things in my head sometimes.

    Im definitely going to start doing some more Marketpress stuff, themes and tutorials etc, and publish them here for people to test etc. Just need to find some time.

    Ive had a look into the code as if you want to make the custom link url a nofollow then I think you would have to change this bit of code found in marketpress-includes/template-functions.php on line 1568

    $button = '<a class="mp_link_buynow" href="' . esc_url($product_link) . '">' . __('Buy Now &raquo;', 'mp') . '</a>';

    change to:

    $button = '<a rel="nofollow" class="mp_link_buynow" href="' . esc_url($product_link) . '">' . __('Buy Now &raquo;', 'mp') . '</a>';

    That should do it for ya!

    sequin

    Thanks so much! I'm getting somewhere at last - this forum rocks!!
    The code you gave me was a great starting point and I'm feeling a lot more confident. The page layout is starting to look much better too - http://www.milkchic.co.uk/store/view-all/

    I've managed to make all the links nofollow using the method above, but can't figure out how to change the permalink to the external product link. The current code I have for the titles is very basic:
    <a rel="nofollow" href="<?php echo the_permalink(); ?>"><?php the_title(); ?>

    I thought the reference for the link was either product_link or mp_product_link but whenever I try to swap out "the_permalink" in this code, the page layout breaks.

    I can change the link on the images to both product_link and mp_product_link without issues, but they both lead to the permalink anyway even on the external test product (HotMilk bra) so I'm obviously using the wrong function.

    ThePath

    Hey sequin, thsnk for the points

    Yes you are right this forum is awesome (remember to spread the word as an affiliate) and has a great community spirit about it. Its much better than the forum over at wordpress.org which can have a feel of elite WP devs looking down on us mere mortals.

    Yeh your sites looking really good. When I checked it though I couldnt see any "buy" buttons on the product list page.

    Could you try this code for me:

    So change:

    <a rel="nofollow" href="<?php echo the_permalink(); ?>"><?php the_title(); ?>

    to:

    <a rel="nofollow" href="<?php esc_url($product_link); ?>"><?php the_title(); ?>

    If youwant to add a buy button with the external link to the product rather than the permalink then I would use/adapt this code from template-functions.php

    <?php '<a class="mp_link_buynow" href="' . esc_url($product_link) . '">' . __('Buy Now &raquo;', 'mp') . '</a>' ?>

    Im not sure if that PHP syntax is right but I guess its a start Im no PHP expert, unfortunately.

    Keep up the good work.

    sequin

    Have tried that code line, but instead of linking to the external url, it just links to my main product list. Same happens when I use $mp_product_link. Glad I'm on the right track with the coding though - it's obviously the references to the external link that I've identified wrongly! Slightly annoying as I spent a few hours getting my head around if & else so I could reference the permalink for my own products, and now I can't find the basic ingredients

    Will checkout that plugin tomorrow and see what they use.

    sequin

    Bit of a Eureka moment! The way to get those additional fields is to use get_meta functions. So to get your external links, you need to use:

    <?php if ( get_post_meta($post->ID, 'mp_product_link', true) ) ; ?>
    <a rel="nofollow" href="<?php echo get_post_meta($post->ID, 'mp_product_link', true) ?>"><?php the_title(); ?></a>
    ?>

    M next task is to figure out how to nest this in an if else function so that my own products call the permalinks instead. Think I need to define a function and then define that as if else, but pretty sure I'll figure it out.

    The image formatting is in more complicated format for me (php not straight html calling php functions) so I'm not sure how to edit the link on that. I may give up and just use a lightbox image onclick instead. If anyone knows the way to edit it, the section of code for my thumbnail image is currently:

    <?php if ( has_post_thumbnail() ) {
            	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
    			echo '<a href="' . large_image_url . '" title="' . the_title_attribute('echo=0') . '" >';
    			mp_product_image();
    			echo '</a>';
             } ?>
             <?php  $id = get_post_thumbnail_id(get_the_ID()); // gets the post thumbnail ID ?>

    Will post the get_meta solution on the main forums as I haven't seen it written out anywhere and if I can do it, it must be an easy option! If my code is badly formatted, feel free to correct.

    ThePath

    Hey sequin, well done! Yeh I should have had a look into the post meta, doh!

    Well surely you have half the if else already so just tack on the else?

    <?php if ( get_post_meta($post->ID, 'mp_product_link', true) )  { ?>
    <a rel="nofollow" href="<?php echo get_post_meta($post->ID, 'mp_product_link', true) ?>"><?php the_title(); ?></a>
    } else {
    <a rel="nofollow" href="<?php echo the_permalink(); ?>"><?php the_title(); ?>
    } ?>

    So if Im right the post meta bit you came up with will return false if nothing is in it and so go to the else? Again dont quote me, lol, I wish I was better at this. Id need to read up more on the post meta function on the codex to be sure.

    So you want the image to have the same link to your external link yes?

    <?php if ( get_post_meta($post->ID, 'mp_product_link', true) )  {
     if ( has_post_thumbnail() ) {
            	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
    			echo '<a href="="<?php echo get_post_meta($post->ID, 'mp_product_link', true) ?>">';
    			mp_product_image();
    			echo '</a>';
    }
    } else {
     if ( has_post_thumbnail() ) {
    $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
    			echo '<a href="<?php echo the_permalink(); ?>">';
    			mp_product_image();
    			echo '</a>';
    }
    } ?>

    Something along those lines perhaps.......i dunno Im a bit sleepy today

    sequin

    I have it figured - so proud of myself and am about to document it for any other newbies struggling.

    Apparently the get_post_meta query generates an empty string even if there is nothing there, so instead of generating nothing in the link, it generates <a href=""> which just gives me a link to the page I'm on. If you use straight if else, the else then generates another link, which gives me duplicate text as well.

    To get it to work properly, you need to use if/else to only query the meta if it has something in it:

    <?php $external = get_post_meta($post->ID, 'mp_product_link', true) ?>
    <?php if(!empty($external)): ?>
    <a rel="nofollow" target=”_blank” href="<?php echo get_post_meta($post->ID, 'mp_product_link', true) ?>"><?php the_title(); ?></a>
    <?php else : ?>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php endif; ?>

    Same format works on the image link

    ThePath

    Hey excellent, well done and good find on the whole returning a blank link.

    Could you clean up code further by doing something like:

    <?php $external = get_post_meta($post->ID, 'mp_product_link', true) ?>
    <?php if(!empty($external)): ?>
    <a rel="nofollow" target=”_blank” href="<?php echo $external ?>"><?php the_title(); ?></a>
    <?php else : ?>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php endif; ?>

    Youve set the external variable so you may as well use it

    Nice work!