Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor ModDish

    (@moddish)

    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;
    Plugin Contributor ModDish

    (@moddish)

    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.

    Thread Starter headingwest

    (@headingwest)

    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.

    Plugin Contributor ModDish

    (@moddish)

    sure.

    Thread Starter headingwest

    (@headingwest)

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

    Plugin Contributor ModDish

    (@moddish)

    evanmugford AT eastlink Dot ca

    Thread Starter headingwest

    (@headingwest)

    Paid, thank you.

    Plugin Contributor ModDish

    (@moddish)

    plugin sent via email, let me know 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Can I add the price to the grid?’ is closed to new replies.