• Resolved danzigism

    (@danzigism)


    Hi all. Before the recent update, I was using a custom function to display the table rate prices on the single product page. Now this has been changed to “Quantity Discounts” so I believe the metadata name value has changed. All of my old products (3000 of them) have the old post metadata name.

    Is there a way to update this to the NEW name?

    Here’s the old function I’m using:

    function add_in_table_rate($product_id){
    	$output = '';
    	$metadata = get_post_meta( $product_id , '_wpsc_product_metadata', true);
    	if(!empty($metadata['table_rate_price']['state']) &&
    		$metadata['table_rate_price']['state'] ){
    		echo '<h3>Discounts available on multiple quantities!</h3>';
    		$output = '';
    		for($i=0; $i < count($metadata['table_rate_price']['quantity']); $i++){
    			$output .= "".$metadata['table_rate_price']['quantity'][$i]." for
    			".wpsc_currency_display($metadata['table_rate_price']['table_price'][$i])." per item <br />";
    		}
    		$output .= '<br />';
    	}
    echo $output;
    }
    add_action('wpsc_product_addon_after_descr','add_in_table_rate');

    Any help you can provide would be greatly appreciated because any new products I add or old products I modify get updated using the new value name.

    Or if anyone has a better way of show the prices of the Quantity Discount I’m also open for other suggestions.

    https://www.ads-software.com/plugins/wp-e-commerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Justin Sainton

    (@justinsainton)

    Hi danzigism,

    The meta key did not actually change, you’ll notice we’re still using that in the core plugin. I believe it was just the metabox title that changed.

    Thread Starter danzigism

    (@danzigism)

    Thanks for the help Justin. I wonder why this function no longer works?

    It works for all of my old products prior to the update.

    If I create a new product and specify a quantity discount, this function no longer displays the price.

    If you can think of a better method I can use to show the quantity discounts on a single product page, I would appreciate your guidance.

    Thank you for the quick reply!

    Plugin Author Justin Sainton

    (@justinsainton)

    Hmm, interesting, this may actually be a regression.

    Here’s the array I’m getting back:

    https://cl.ly/image/3u2s0H271k1h

    There’s no state key there, but there should be…time to dig in!

    Thread Starter danzigism

    (@danzigism)

    I went ahead and removed [state] from the conditional statement and it definitely works now on all products. After doing so, I was noticing that my particular function was still returning that table_rate_price is always TRUE regardless if there was a price associated with multiple quantities.

    So I simply added [‘table_rate_price’][‘table_price’] and now my code shows up on every product page that has multiple quantity discounts!

    Sweet. Thanks for your help in diagnosing the problem.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Table Rate Price/Quantity Discount Metadata Name Change’ is closed to new replies.