WordPress.org

Ready to get started?Download WordPress

Forums

WP eCommerce
Apply filters to price? (1 post)

  1. chavo
    Member
    Posted 4 months ago #

    Hi. I'm trying to apply a simple global filter to prices displayed in all instances (simple product page, shopping cart page, emails, etc.).

    I guess that this is possible with a small apply filters function but it isn't working for me (I'm not a code master).

    I take some basic code from wpsc_calculate_price function in product-template.php

    Can anyone help me to get in the right direction?

    This is the code that I add to my functions.php file:

    function wpsc_modify_price() {
    	global $wpdb;
    	$product_id = get_the_ID();
    	$sql = "SELECT <code>post_id</code> FROM ".$wpdb->postmeta." WHERE <code>meta_key</code> = '_wpsc_price'";
    	$product_id = $wpdb->get_var($sql);
    
    	$price = get_post_meta( $product_id, '_wpsc_price', true );
    
            // simple test
    	$price = $price*100;
    
    	$price = apply_filters( 'wpsc_price', $price, $product_id );
    	return $price;
    }

    Thanks in advance!

    https://wordpress.org/plugins/wp-e-commerce/

Reply

You must log in to post.

About this Plugin

About this Topic