WP eCommerce
Apply filters to price? (1 post)

  1. chavo
    Posted 1 year 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!


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic