Advertisement
sparkweb

FoxyShop: Custom Pricing Based on Subscription Status

Nov 28th, 2011
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //Price based on membership. Checks if user is a current subscriber and displays the members only price if applicable.
  2. //Thanks to Ryan for code sharing
  3. //Put this in functions.php
  4.  
  5. //Manual Price Adjustment
  6. add_filter('foxyshop_setup_product_info', 'members_price', 10, 2);
  7. function members_price($product, $product_id) {
  8. $pricing_levels = get_post_meta($product_id,'_pricing_levels',1);
  9. if (foxyshop_subscription_active(42) == '1'){
  10. if ($pricing_levels) {
  11. $newprice = $pricing_levels;
  12. $product['price'] = $newprice;
  13. }
  14. }
  15. return $product;
  16. }
  17.  
  18.  
  19.  
  20. //Show New Field in Admin
  21. add_action('foxyshop_admin_product_details','my_custom_pricing_levels_meta');
  22. function my_custom_pricing_levels_meta($post_id) {
  23. $_pricing_levels = get_post_meta($post_id,'_pricing_levels',1);
  24. ?>
  25. <label for="_pricing_levels">Subscriber Pricing</label>
  26. <input type="text" name="_pricing_levels" id="_pricing_levels" value="<?php echo $_pricing_levels ?>" />
  27. <?php
  28. }
  29.  
  30.  
  31. //Save New Field
  32. add_action("foxyshop_save_product","my_custom_pricing_levels_meta_save");
  33. function my_custom_pricing_levels_meta_save($post_id) {
  34. global $post_id;
  35. foxyshop_save_meta_data("_pricing_levels",$_POST["_pricing_levels"]);
  36. return $post_id;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement