Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Price based on membership. Checks if user is a current subscriber and displays the members only price if applicable.
- //Thanks to Ryan for code sharing
- //Put this in functions.php
- //Manual Price Adjustment
- add_filter('foxyshop_setup_product_info', 'members_price', 10, 2);
- function members_price($product, $product_id) {
- $pricing_levels = get_post_meta($product_id,'_pricing_levels',1);
- if (foxyshop_subscription_active(42) == '1'){
- if ($pricing_levels) {
- $newprice = $pricing_levels;
- $product['price'] = $newprice;
- }
- }
- return $product;
- }
- //Show New Field in Admin
- add_action('foxyshop_admin_product_details','my_custom_pricing_levels_meta');
- function my_custom_pricing_levels_meta($post_id) {
- $_pricing_levels = get_post_meta($post_id,'_pricing_levels',1);
- ?>
- <label for="_pricing_levels">Subscriber Pricing</label>
- <input type="text" name="_pricing_levels" id="_pricing_levels" value="<?php echo $_pricing_levels ?>" />
- <?php
- }
- //Save New Field
- add_action("foxyshop_save_product","my_custom_pricing_levels_meta_save");
- function my_custom_pricing_levels_meta_save($post_id) {
- global $post_id;
- foxyshop_save_meta_data("_pricing_levels",$_POST["_pricing_levels"]);
- return $post_id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement