• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2893

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Checkout

Weekly Discount For Custom Contributors Role Based on Count of Users Posts

$75.00

Category: WooCommerce Tags: add_fee, add_role, count_user_posts, get_current_user_id, get_option, get_role, get_subtotal, global $wpdb, in_array, is_user_logged_in, update_option, wc_add_notice, woocommerce_cart_calculate_fees, wp_get_current_user
  • Description

The 80 lines of PHP code in this download include 3 custom functions which enable the store owner to give a percentage discount on the cart subtotal to contributors who submit a set number of posts. Otherwise, a notice is displayed to logged in reviewers warning the discount is only available once a week.

No discount as not a logged in contributor
No discount as not a logged in contributor
Discount already used this week
Discount already used this week
Discount applied as hasn't used and has published post
Discount applied as hasn’t used and has published post

The custom functions hooked to the woocommerce_cart_calculate_fees action are :

purchased_this_week() Returns true if the current user has purchased a product within the last week. You can set this function to any time frame.

reviewer_update_custom_role() Adds a custom role named Product Reviewer which matches the default contributor role capabilities. You can set this to any default role or custom role with an array of custom capabilities.

is_a_reviewer() Checks if the current logged in user has the Product Reviewer role.

Code Installation

Copy & paste the PHP code to the end of your child themes functions.php file or custom functionality plugin.

Primary Sidebar

Guaranteed code

Written by Brad Dalton specialist for WooCommerce. Read More…

Advertise · WPEngine · Genesis · Log in

  • Code Snippets
  • Tutorials
  • Videos
  • Tags
  • Account
  • Checkout
  • Cart
  • Hire Me
 

Loading Comments...
 

You must be logged in to post a comment.