Skip to content

Instantly share code, notes, and snippets.

View m3esma's full-sized avatar
💻
Coding

Mehdi Esmaeili m3esma

💻
Coding
View GitHub Profile
@m3esma
m3esma / functions.php
Created November 30, 2019 15:08
WooCommerce - Disable purchase for non-logged-in users. (Remove add-to-cart button).
<?php
// Do NOT include the opening php tag.
// Disable purchase for non-logged-in users. (Remove add-to-cart button).
function m3wc_woocommerce_is_purchasable( $is_purchasable, $product ) {
if ( ! is_user_logged_in() ) {
return false;
}
return $is_purchasable;
@m3esma
m3esma / functions.php
Created November 30, 2019 10:53
WooCommerce - Custom pricing.
<?php
// Do NOT include the opening php tag.
// Set custom price.
function m3wc_woocommerce_product_get_price( $price, $product ) {
// Do any calculations or conditions here.
// For example1: Set a different price for each type of user.
// For example2: $price = $price + ( $price * 0.09 ); Adding 9% of the price.