WordPress.org

Ready to get started?Download WordPress

Forums

MarketPress - WordPress eCommerce
[resolved] Single product view (17 posts)

  1. SalvisB
    Member
    Posted 11 months ago #

    Hello!
    What function/s should I use to display product information (title, image, description, price etc.) when creating single product view page - mp_product.php.

    http://wordpress.org/plugins/wordpress-ecommerce/

  2. Mike
    WPMU DEV Support Staff
    Posted 11 months ago #

    Hi @SalvisB

    The functions you need to use are documented in the following file:
    /marketpress/marketpress-includes/template-functions.php

  3. SalvisB
    Member
    Posted 11 months ago #

    It's much easier than I think it would be. :)
    Only a few problems... 1) Don't know how to display hierarchy of categories where product is placed.
    Screenshot shows what I mean by that: http://screencast.com/t/cA72q2r5j0 (can't display this section on my mp_product page).
    As far as I know for this section responsible is function
    <?php mp_category_list(); ?> , but it displays nothing. Maybe I just need to pass some parameters in this function?
    2) Another problem is that when I use function <?php mp_product_image(); ?> for image width and height it takes parameters from 'thumbnail size' both for 'single product image settings' and 'product list image settings'. When I switch single image settings to display medium or custom size images, nothing happens.

  4. Mike
    WPMU DEV Support Staff
    Posted 11 months ago #

    Hi @SalvisB

    1) Is this not the mp_list_categories functions? Have you tried that?

    2) The mp_product_image function lists this:
    function mp_product_image($echo = true, $context = 'list', $post_id = NULL, $size = NULL)

    The first argument $echo can be true or false. This would normally be true as you'll see from the default above.
    $context can be: list, single, widget
    $post_id would probably be set to: $post->ID
    $size would be a number(perhaps "array(150,150)")

    So the final call would be something like:
    mp_product_image(true,single,$post->ID,array(150,150))

    Now please bear in mind, I'm not a coder by any stretch of the imagination, so the above could be completely wrong, please don't expect too much :-)

  5. SalvisB
    Member
    Posted 10 months ago #

    Thanks Mike! Code for displaying product image works great! :) But I still can't find right function to allow display categories in the bottom of product.
    Function mp_list_categories displays all the product category tree (as in sitemap), but I need only those categories where the product is placed (as in screenshot which I provided - http://screencast.com/t/cA72q2r5j0.

    Any ideas?

  6. Hi there @SalvisB

    Greetings, hope your well today.

    This code

    <?php echo wp_get_post_terms( $post->ID, 'product_category' ); ?>

    Should do that for you :)

    Thank you!

    Kind Regards
    Jack.

  7. SalvisB
    Member
    Posted 10 months ago #

    Thanks, Jack.
    I will try it out and let you know how it did..

  8. SalvisB
    Member
    Posted 10 months ago #

    It doesn't work. The thing what it does - it just echo's string of "Array".
    Screenshot: http://screencast.com/t/HkZLG5b57GT

  9. Hi there @SalvisB,

    I hope you are well today.

    Sorry about that, this should work

    <?php $terms = wp_get_post_terms( $post->ID, 'product_category' ); print_r( $terms ); ?>

    Thank you!

    Kind Regards
    Jack.

  10. SalvisB
    Member
    Posted 10 months ago #

    Screenshot: http://screencast.com/t/VbgURAGexuJD
    Closer, but still with mistakes (outputs unnecessary information) and without styling. ;/

  11. Hi there @SalvisB,

    I hope you are well today.

    This should work :) I promise! :)

    <?php
    $terms = wp_get_post_terms( $post->ID, 'product_category' );
    foreach ( $terms as $term  ) :
       echo $term['slug'];
    endforeach;

    Thanks!

    Kind Regards
    Jack.

  12. SalvisB
    Member
    Posted 10 months ago #

    Hi Jack!
    Still nothing. :)
    Now it's even worse. By adding that line of code it removes everything else excpet information about product and it's image, but still without category listing.

    Before:
    http://screencast.com/t/zioU6cym3Rx

    After adding that code:
    http://screencast.com/t/0qOLm8nl4

  13. David
    WPMU DEV Support Staff
    Posted 9 months ago #

    Hi SalvisB,

    Could you please add the following onto the end of Jack's last snippet and let us know how that works for you?

    ?>

    Thanks,
    DavidM

  14. Ashok
    WPMU DEV Support Staff
    Posted 9 months ago #

    Just chiming in here.

    Would you please try the following code:

    $terms = wp_get_post_terms( $post->ID, 'product_category' );
    foreach($terms as $term) {
    echo $term->name . ', ';
    }

    Please try this and let me know if it improves something.

    Cheers
    Ash

  15. SalvisB
    Member
    Posted 9 months ago #

    Hi Ash!
    By using your code it outputs necessary categories like it should, but there is a few gaps:
    1) Categories are displayed as a plain text, not as a links like it should be.
    2) It misses styling.
    3) Comma ',' are placed after last category aswell, as it shouldn't be.

    I can correct styling issue, but don't know how to correct point 1 and 2.

    With best wishes,
    Salvis

  16. David
    WPMU DEV Support Staff
    Posted 9 months ago #

    Hi SalvisB,

    The following should take care of that:

    $html = '<div class="mp_product_categories">';
    $terms = wp_get_post_terms( $post->ID, 'product_category' );
    $termCount = count($terms);
    $i = 0;
    foreach($terms as $term) {
    	$html .= '<a href="'. get_term_link($term) . '">';
    	$html .= $term->name . '</a>';
    	if(++$i !== $termCount) {
    		$html .= ', ';
    	}
    }
    $html .= '</div>';
    echo $html;

    It should also take on the standard MarketPress styling since it adds a div with the mp_product_categories class. Or you could target it with that class to change it.

    Cheers,
    DavidM

  17. WPMUDEV
    WPMU DEV Support Staff
    Plugin Author

    Posted 9 months ago #

    Hey there.

    We haven't heard from you in awhile, so I just wanted to check in to make sure all was good.

    This thread was marked resolved, but please, if you still need help then just respond and open it back up. We can then take it from there. :)

    Hope you have a fantastic day!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.