WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a client that wants to charge different shipping rates based on a size variant (small, medium, large).

She does not have the weights or size in inches of each item, she only wants to assign the shipping for each item based on whether the shopper chooses small, medium, large or extra large for the size of the item.

Is there a way to assign a shipping price in WP e-commerce using a variant and still have it show as the shipping cost?

share|improve this question

closed as off-topic by Mark Kaplun, Johannes Pille, birgire, Pieter Goosen, ialocin Oct 5 '14 at 15:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, Johannes Pille, birgire, Pieter Goosen, ialocin
If this question can be reworded to fit the rules in the help center, please edit the question.

Read this: http://docs.getshopped.org/documentation/creating-variations/

Picture this: James wants to create a store to sell T-shirts. Once he starts building his product catalog, he realizes that he needs a way for customers to specify what size shirt they want. He shudders to think that he might need to create a separate product listing for each size of each shirt. Not only would that be extremely time-consuming, it would be confusing for potential customers. Isn’t there an easier way? Yes! Variations are exactly what James needs. By creating a variation for size, he can create one listing for each shirt and have customers simply choose a size from a drop-down list. As an added benefit, if he needs to charge extra for an irregular size, variations can handle that, too.

Beyond that,

There is this wp-ecommerce core filter Located in: cart.class.php;

function wpsc_cart_shipping() {
   global $wpsc_cart;
   return apply_filters( 'wpsc_cart_shipping', wpsc_currency_display( $wpsc_cart->calculate_total_shipping() ) );

Which means you could filter the price based on a variable,

function my_variable_price(){
   //do your logic here
   //based on size selected
add_filter('wpsc_cart_shipping', 'my_variable_price'); 

This is intended as a guide, not a 1:1 solution, since your problem is localized to your use-case, we'd need more information about how you are setting size options. Whether its held in post meta, or via some other means. But, I'd seriously look into the first link provided before going down this path.

share|improve this answer
THe link is just what I have tried. It is very easy to implement, but it changes the price of the item and the shipping does not reflect a change in price. I know that's anal, but the client wants the price of the item to remain constant and change the shipping based on the size. I will talk to her today about assigning a base shipping price (like the shipping price for a small item) and just adding to the cost of the actual item fi a larger size is chosen. – user21398 Oct 12 '12 at 19:52
In order to properly calculate shipping in the code, you'd need to cycle through all of the items in the cart, and add the shipping charges based on each item's size. I'm not sure I'm up to that. It sure would be nice to have the ability to assign shipping costs based on a variable that actually showed the amount as a change in shipping costs - not by varying the item's price. – user21398 Oct 12 '12 at 19:58
@user21398 If the standard variations method as provided in the first link doesn't extend to allow for your clients use-case then you'll definitely need to be working with action hooks and filters to get the job done (as shown above). If that's beyond what you can do currently, I'd suggest outsourcing the task, unless someone who already has wp-ecommerce installed is kind enough to write and test an example filter based on said requirements. I may investigate further during the week when time permits. But I do agree that it would be nice to have that ability overall. – userabuser Oct 13 '12 at 3:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.