WordPress.org

Ready to get started?Download WordPress

Forums

Grid Products
Can I add the price to the grid? (9 posts)

  1. headingwest
    Member
    Posted 1 year ago #

    Hi, is there any way to add the price to the grid?

    BTW cart66 is screaming out for a good grid, you could sell this if you get it working well. I've spent hours trying to layout my products.

    http://wordpress.org/extend/plugins/grid-products/

  2. ModDish
    Member
    Plugin Contributor

    Posted 1 year ago #

    Hey

    yes you could add fields to the products to support pricing.

    add something like this to line 24

    //--------------------------------------------PRODUCT PRICE------------------------------------------
    //--------------------------------------------PRODUCT PRICE------------------------------------------
    //--------------------------------------------PRODUCT PRICE------------------------------------------
    
    add_action( 'add_meta_boxes', '_grid_product_price_box' );
    function _grid_product_price_box() {
        add_meta_box(
            '_grid_product_price_box',
            __( 'Property Details', '_grid_product_price' ),
            '_grid_product_price_box_content',
            'grid_products',
            'side',
            'high'
        );
    }
    
    function _grid_product_price_box_content( $post ) {
    	wp_nonce_field( plugin_basename( __FILE__ ), '_grid_product_price_box_content_nonce' );
    	echo '<div class="listingfieldholder">Price: </div><input type="text" id="_grid_product_price" name="_grid_product_price" placeholder="Property Price" class="admininputfield"value="'.get_post_meta( $_GET[post], '_grid_product_price', true ).'"> <br/>';
    }
    
    add_action( 'save_post', '_grid_product_price_box_save' );
    function _grid_product_price_box_save( $post_id ) {
    
    	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
    	return;
    
    	if ( !wp_verify_nonce( $_POST['_grid_product_price_box_content_nonce'], plugin_basename( __FILE__ ) ) )
    	return;
    
    	if ( 'post' == $_POST['post_type'] ) {
    		if ( !current_user_can( 'edit_page', $post_id ) )
    		return;
    	} else {
    		if ( !current_user_can( 'edit_post', $post_id ) )
    		return;
    	}
    
    update_post_meta( $post_id, '_grid_product_price', $_POST['_grid_product_price'] );
    }
    
    //--------------------------------------------PRODUCT PRICE END------------------------------------------
    //--------------------------------------------PRODUCT PRICE END------------------------------------------
    //--------------------------------------------PRODUCT PRICE END------------------------------------------

    then to echo it

    $price=get_post_meta( get_the_ID(), '_grid_product_price', true );
    echo $price;
  3. ModDish
    Member
    Plugin Contributor

    Posted 1 year ago #

    you can reuse the about to add as many fields as you like, just siply duplicate this line

    echo '<div class="listingfieldholder">Price: </div><input type="text" id="_grid_product_price" name="_grid_product_price" placeholder="Property Price" class="admininputfield"value="'.get_post_meta( $_GET[post], '_grid_product_price', true ).'"> <br/>';

    and this line

    'update_post_meta( $post_id, '_grid_product_price', $_POST['_grid_product_price'] );'

    changing the field name _grid_product_price to _grid_product_whatever in all instances of the duplicated lines.

    I used this for a property site, and added all the property listing fields to the products, then created a single template to echo them all.

  4. headingwest
    Member
    Posted 1 year ago #

    Sorry ModDish, I'm no developer. If I donate $20 to the plugin can you add this price field? A lot of people will use it.

  5. ModDish
    Member
    Plugin Contributor

    Posted 1 year ago #

    sure.

  6. headingwest
    Member
    Posted 1 year ago #

    Cool. Your donate button goes to Toronto printing. How do I donate? Do you have a paypal email??

  7. ModDish
    Member
    Plugin Contributor

    Posted 1 year ago #

    evanmugford AT eastlink Dot ca

  8. headingwest
    Member
    Posted 1 year ago #

    Paid, thank you.

  9. ModDish
    Member
    Plugin Contributor

    Posted 1 year ago #

    plugin sent via email, let me know :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags