Marketpress zero prices in Product Listing view

In product listing view of Marketpress, it would be very useful on some products to display some text instead of a price.

e.g. when price = 0 display 'Contact Us for pricing' or 'Pricing coming soon' or even just 'blank' rather than £0

Is there a hook or some other easy way of achieving this?

  • aecnu

    Greetings Alan,

    Thank you for the great observation and once again I totally agree with this to be a possible option.

    I found the code for the money graphic to be in the css like this:

    .mp_product_price {
    line-height: 40px;
    background: url('modern-images/money.png') no-repeat 0 2px;
    margin-right: 10px;
    padding: 0px 0px 0px 20px;
    }

    Digging into this it appears that the 0.00 can be completely removed by removing the lines in the template-functions.php or replacing with text the mp_current_price if using short codes, and theme dependent otherwise i.e. Grid Market

    UPDATE: that did not work out as anticipated.

    Therefore I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Fullworks

    Joe, I think I have found it.

    Grid Market calls a Frame market function called
    framemarket_grid_mp_list_products

    that calls a plugin function

    mp_product_price()

    that has a filter

    $price = apply_filters( 'mp_product_price_tag', '<span class="mp_product_price">' . $label . $price . '</span>', $post_id, $label );

    Hurray

    so I should be able to write something like, unfortunately need to do lots of processing to find the first price. Not 100% why some of that code is there. Not tested yet,but should be close, I think.

    add_filter('mp_product_price_tag','my_price_function',10,3);
    
    function my_price_function($input,$post_id,,$label) {
    global $id, $mp;
    $meta = get_post_custom($post_id);
    foreach ($meta as $key => $val) {
    	  $meta[$key] = maybe_unserialize($val[0]);
    	  if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file" && $key != "mp_price_sort")
    	    $meta[$key] = array($meta[$key]);  //no idea if I need this
    	}
    
    if ($meta["mp_price"][0]==0) {
       $output='<span class="myzero">MY ZERO TEXT</span>';
    } else {
       $output=$input;
    }
    return $output;
    }
  • Fullworks

    Just for completeness, in case other stumble over this

    the following code added to my theme's functions.php, is the debugged version and changes zero prices to text ONLY when in 'product listing only' mode

    add_filter('mp_product_price_tag','my_price_function',10,3);
    
    function my_price_function($input,$post_id,$label) {
    global $id, $mp;
    $meta = get_post_custom($post_id);
    foreach ($meta as $key => $val) {
    	  $meta[$key] = maybe_unserialize($val[0]);
    	  if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file" && $key != "mp_price_sort")
    	    $meta[$key] = array($meta[$key]);  //no idea if I need this
    	}
    
    if (($meta["mp_price"][0]==0) && ($mp->get_setting('disable_cart'))) {   // only replace on product listing only
       $output='<span class="myzero">Price coming soon</span>';
    } else {
       $output=$input;
    }
    return $output;
    }
  • aecnu

    Greetings Dave,

    I would think at the bottom is spot on.

    have you also tried Market Press 2.8.1 and also it would be the functions.php file in Grid Market it being the child theme - IF you have them configured correctly.

    Please see:

    https://premium.wpmudev.org/forums/topic/front-page-blogs-picture-and-text-not-visible-only-subject-is-visible#post-217131

    The above shows the correct Parent/Child configuration and that you only enable the child.

    Please advise and in any event have a GREAT upcoming weekend!

    Cheers, Joe

  • dave_browning

    Really not having a win here, I have tried placing that code snippet at the bottom (as per below:-
    When I do it it gives me an internal server error, there must be a requirement to put the code in a certain place within this file? I realllllly want this feature!

    <?php
    add_action( 'after_setup_theme', 'gridmarket_setup', 10 );
    function gridmarket_setup() {	
    
    		global $content_width;
    		if ( ! isset( $content_width ) ) {
    			$content_width = 720;
    		}
    	} 
    
    function framemarket_enqueue_styles(){
    	$version = '1.4';
    
    	global $bp_existed;
    
    	if ( (!is_admin()) && ($bp_existed == 'true') ) {
    		wp_enqueue_style( 'buddypress-default', get_template_directory_uri() . '/buddypress/bp-default.css', array( 'framemarket' ), $version);
    	}
    
    	if ( !is_admin() ) {
    		wp_enqueue_style( 'framemarket', get_template_directory_uri() . '/css/framemarket.css', array(), $version);  
    
    		wp_enqueue_style( 'gridmarket', get_stylesheet_directory_uri() . '/css/grid.css', array( 'framemarket' ), $version); 
    
    				$themename = wp_get_theme();
    				$themeinput = $themename . '_styleinput';
    
    				$options = get_option('framemarket_theme_options');
    				$stylesheet = isset($options[$themeinput]) ? $options[$themeinput] : '';
    
    				if ($stylesheet != ""){
    					wp_enqueue_style( 'gridmarket_style', get_stylesheet_directory_uri() .  '/styles/' . $stylesheet . '.css', array( 'framemarket' ), $version); 
    
    				}
    				else{
    				wp_enqueue_style( 'gridmarket_orange', get_stylesheet_directory_uri() . '/styles/darkorange.css', array( 'framemarket' ), $version);
    				} 
    
    				wp_enqueue_style( 'gridmarket_custom', get_stylesheet_directory_uri() . '/css/custom.css', array( 'framemarket' ), $version);
    			 }
    
    }
    
    function gridmarket_widgets_init() {
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer one', 'framemarket' ),
    			'id'            => 'footer-one',
    			'description'   => 'Footer one',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer two', 'framemarket' ),
    			'id'            => 'footer-two',
    			'description'   => 'Footer two',
    		'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer three', 'framemarket' ),
    			'id'            => 'footer-three',
    			'description'   => 'Footer three',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer four', 'framemarket' ),
    			'id'            => 'footer-four',
    			'description'   => 'Footer four',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer five', 'framemarket' ),
    			'id'            => 'footer-five',
    			'description'   => 'Footer five',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s end">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    }
    add_action( 'widgets_init', 'gridmarket_widgets_init' );
    require_once ( get_stylesheet_directory() . '/functions/theme.php' );
    
    //add a custom css change to hide something in the dashboard
    function change_css_hide_wpmu_dash()
    {
        echo '<style type="text/css"> .wp-admin div.error {display: none !important;}</style>';
    }
    add_action('all_admin_notices', 'change_css_hide_wpmu_dash');
    
    add_filter('mp_product_price_tag','my_price_function',10,3);
    
    function my_price_function($input,$post_id,$label) {
    global $id, $mp;
    $meta = get_post_custom($post_id);
    foreach ($meta as $key => $val) {
    	  $meta[$key] = maybe_unserialize($val[0]);
    	  if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file" && $key != "mp_price_sort")
    	    $meta[$key] = array($meta[$key]);  //no idea if I need this
    	}
    
    if (($meta["mp_price"][0]==0) && ($mp->get_setting('disable_cart'))) {   // only replace on product listing only
       $output='<span class="myzero">Price coming soon</span>';
    } else {
       $output=$input;
    }
    return $output;
    }
    
    ?>
  • Fullworks

    Looks like your cut and paste has stuck it all on one line. That would cause issues with the in-line comments.

    Here is a snip without inline comments

    If you want text file with the carriage returns in just e-mail me, its in my profile

    add_filter('mp_product_price_tag','my_price_function',10,3);
    
    function my_price_function($input,$post_id,$label) {
    global $id, $mp;
    $meta = get_post_custom($post_id);
    foreach ($meta as $key => $val) {
    	  $meta[$key] = maybe_unserialize($val[0]);
    	  if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file" && $key != "mp_price_sort")
    	    $meta[$key] = array($meta[$key]);
    	}
    
    if (($meta["mp_price"][0]==0) && ($mp->get_setting('disable_cart'))) {
       $output='<span class="myzero">Price comming soon</span>';
    } else {
       $output=$input;
    }
    return $output;
    }
  • dave_browning

    Same issue!

    This is my ENTIRE functions.php file that is under /wp-content/themes/gridmarket

    <?php
    add_action( 'after_setup_theme', 'gridmarket_setup', 10 );
    function gridmarket_setup() {	
    
    		global $content_width;
    		if ( ! isset( $content_width ) ) {
    			$content_width = 720;
    		}
    	} 
    
    function framemarket_enqueue_styles(){
    	$version = '1.4';
    
    	global $bp_existed;
    
    	if ( (!is_admin()) && ($bp_existed == 'true') ) {
    		wp_enqueue_style( 'buddypress-default', get_template_directory_uri() . '/buddypress/bp-default.css', array( 'framemarket' ), $version);
    	}
    
    	if ( !is_admin() ) {
    		wp_enqueue_style( 'framemarket', get_template_directory_uri() . '/css/framemarket.css', array(), $version);  
    
    		wp_enqueue_style( 'gridmarket', get_stylesheet_directory_uri() . '/css/grid.css', array( 'framemarket' ), $version); 
    
    				$themename = wp_get_theme();
    				$themeinput = $themename . '_styleinput';
    
    				$options = get_option('framemarket_theme_options');
    				$stylesheet = isset($options[$themeinput]) ? $options[$themeinput] : '';
    
    				if ($stylesheet != ""){
    					wp_enqueue_style( 'gridmarket_style', get_stylesheet_directory_uri() .  '/styles/' . $stylesheet . '.css', array( 'framemarket' ), $version); 
    
    				}
    				else{
    				wp_enqueue_style( 'gridmarket_orange', get_stylesheet_directory_uri() . '/styles/darkorange.css', array( 'framemarket' ), $version);
    				} 
    
    				wp_enqueue_style( 'gridmarket_custom', get_stylesheet_directory_uri() . '/css/custom.css', array( 'framemarket' ), $version);
    			 }
    
    }
    
    function gridmarket_widgets_init() {
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer one', 'framemarket' ),
    			'id'            => 'footer-one',
    			'description'   => 'Footer one',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer two', 'framemarket' ),
    			'id'            => 'footer-two',
    			'description'   => 'Footer two',
    		'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer three', 'framemarket' ),
    			'id'            => 'footer-three',
    			'description'   => 'Footer three',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer four', 'framemarket' ),
    			'id'            => 'footer-four',
    			'description'   => 'Footer four',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Footer five', 'framemarket' ),
    			'id'            => 'footer-five',
    			'description'   => 'Footer five',
    			'before_widget' => '<div id="%1$s" class="footer-widget side widget %2$s end">',
            	'after_widget' => '</div>',
            	'before_title' => '<h3 class="widgettitle">',
            	'after_title' => '</h3>'
    		)
    	);
    }
    add_action( 'widgets_init', 'gridmarket_widgets_init' );
    require_once ( get_stylesheet_directory() . '/functions/theme.php' );
    
    //add a custom css change to hide something in the dashboard
    function change_css_hide_wpmu_dash()
    {
        echo '<style type="text/css"> .wp-admin div.error {display: none !important;}</style>';
    }
    add_action('all_admin_notices', 'change_css_hide_wpmu_dash');
    
    add_filter('mp_product_price_tag','my_price_function',10,3);
    
    function my_price_function($input,$post_id,$label) {
    global $id, $mp;
    $meta = get_post_custom($post_id);
    foreach ($meta as $key => $val) {
    	  $meta[$key] = maybe_unserialize($val[0]);
    	  if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file" && $key != "mp_price_sort")
    	    $meta[$key] = array($meta[$key]);
    	}
    
    if (($meta["mp_price"][0]==0) && ($mp->get_setting('disable_cart'))) {
       $output='<span class="myzero">Price comming soon</span>';
    } else {
       $output=$input;
    }
    return $output;
    }
    
    ?>
  • dave_browning

    My mistake! The 500 error caused because it the functions.php had the code snippet that you put here twice!

    I've tidied up so that the snippet is now ONLY in the /wp-content/themes/gridmarket/functions.php file

    But, It does nothing. The prices are still zero. See http://spafactory.proliveonline.com.au/

    HELP!

    PS - I realise there is no obligation for your support and I really appreciate your assistance so far

    Cheers,
    Dave

  • Fullworks

    Once again, it looks like , from you cut and paste you have everything on one line on line 82 and there is an inline comment
    //add a custom css change to hide something in the dashboard
    in the middle of that line, which may be actually commenting out everything after that comment.

    What text editor are you using BTW?

    If you don't understand me, or thing that line 832 isn't all on one line, e-mail me you functions.php and I'll check it, put it on test server and see if I get the problem.

  • aecnu

    Greetings Dave,

    We have not heard back from you as to the status of this issue.

    If you are still having an issue please let us know so that we may try to get you fixed up as soon as possible by choosing to check mark this ticket as unresolved below and posting any new errors or symptoms you are noticing.

    This action will also bring your ticket up front back in plain view again within the ticket system.

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

  • Fullworks

    Hi, I have looked into this and my code only works when the store is set to "Product Listings Only" = yes

    When "Product Listings Only" is set to no, the price shows & the add to basket shows.

    I'm guessing that you have 'cart' turned on.

    This is deliberately in the code

    if (($meta["mp_price"][0]==0) && ($mp->get_setting('disable_cart'))) {

    to show this when the cart is enabled change it to

    if (($meta["mp_price"][0]==0) ) {

    but also make sure inventory is 'on' and stock set to zero for that item, or the add to cart button will show which won't make sense

  • armadacom

    Hi,

    Thanks a lot roboit, your function works great.
    I was wondering if it's possible to use it when the "Product listing" is "yes"
    Some of our products have fixed priced, other depends on many criterias and need a custom estimate. I used this in my function.php :

    add_filter('mp_product_price_tag','my_price_function',10,3);

    function my_price_function($input,$post_id,$label) {
    global $id, $mp;
    $meta = get_post_custom($post_id);
    foreach ($meta as $key => $val) {
    $meta[$key] = maybe_unserialize($val[0]);
    if (!is_array($meta[$key]) && $key != "mp_is_sale" && $key != "mp_track_inventory" && $key != "mp_product_link" && $key != "mp_file" && $key != "mp_price_sort")
    $meta[$key] = array($meta[$key]); //no idea if I need this
    }

    if (($meta["mp_price"][0]==0)) {
    $output='<span class="myzero">On estimate</span>';
    } else {
    $output=$input;
    }
    return $output;
    }

    The text is displayed, but then I need to hide the purchase button. I don't know If it's possible and how to achieve it. Could somebody help ?

    Thanks

  • aecnu

    Greetings armadacom,

    Thank you for asking and though custom coding is beyond the scope of the support we provide here we do try to help if we can.

    Since we have not heard from the original member regarding this custom coding the only things I can recommend not being a coder myself are tweaky.com ~or~ alternatively you could see if there's a developer available at wpmu jobs who could get onto it right this minute

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

  • Fullworks

    Hi,

    I thought I answered this question

    I was wondering if it's possible to use it when the "Product listing" is "yes"

    In the post a couple above.

    Regarding the hiding of the purchase button, I assume that this could be done simply by CSS. Otherwise perhaps by coding a filter, but I haven't looked at this.

    I don't quite get why you want to hide it. It seems a pretty specialised requirement and probably best hiring an hour or two of an expert's time.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.