Skip to content

Instantly share code, notes, and snippets.

View femiyb's full-sized avatar
🏠
Working from home

Femi YB femiyb

🏠
Working from home
View GitHub Profile
@femiyb
femiyb / virtual_product_expiration.php
Last active February 4, 2025 10:54
Set Expiration Date for a Virtual Product in WooCommerce
<?php
// Set expiration date for virtual products when the order is marked complete
add_action('woocommerce_order_status_completed', 'set_user_virtual_product_expiration', 10, 1);
function set_user_virtual_product_expiration($order_id) {
$order = wc_get_order($order_id);
$user_id = $order->get_user_id();
if (!$user_id) return; // Ensure it's a registered user
@femiyb
femiyb / ppcp_remove_single_product_buttons.php
Created November 6, 2024 10:14
hides the PayPal button on single product pages for products in a specific category
function ppcp_remove_single_product_buttons( $enable_button, $product ) {
if ( has_term( 'excluded-category-slug', 'product_cat', $product->get_id() ) ) {
$enable_button = false;
}
return $enable_button;
}
add_filter( 'woocommerce_paypal_payments_product_supports_payment_request_button', 'ppcp_remove_single_product_buttons', 10, 2 );
@femiyb
femiyb / gist:f527c23ce48e4d29bef69d61d2b69517
Created February 10, 2022 13:13 — forked from InpsydeNiklas/gist:8bf70de406a2ff8afef3aa7c2fcff7ac
List of available hooks for PayPal Payments smart buttons
woocommerce_paypal_payments_checkout_button_renderer_hook
woocommerce_paypal_payments_checkout_dcc_renderer_hook
woocommerce_paypal_payments_pay_order_dcc_renderer_hook
woocommerce_paypal_payments_proceed_to_checkout_button_renderer_hook
woocommerce_paypal_payments_mini_cart_button_renderer_hook
woocommerce_paypal_payments_single_product_renderer_hook
@femiyb
femiyb / minimum_cart_cat.php
Created November 19, 2021 16:35
WooCommerce Minimum Cart Total per category
function cat_cart_count( $cat_name ) {
$cat_count = 0;
// Iterating through each cart item
foreach(WC()->cart->get_cart() as $cart_item)
if( has_term( $cat_name, 'product_cat', $cart_item['product_id']))
$cat_count += $cart_item['quantity'];
return $cat_count;
}
@femiyb
femiyb / App.css
Created October 3, 2021 18:25 — forked from adrianhajdin/App.css
/* CHAT STYLES */
* {
font-family: Avenir, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji,
Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
letter-spacing: 0.5px;
}
.ce-chat-list {
background-color: rgb(240, 240, 240) !important;
@femiyb
femiyb / custom_pmproeewe_email_frequency.php
Last active August 19, 2021 10:42 — forked from kimcoleman/custom_pmproeewe_email_frequency.php
Filter the settings of email frequency when using the Extra Expiration Warning Emails Add On
<?php
/**
* Filter the settings of email frequency sent when using the Extra Expiration Warning Emails Add On
* https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/
*
* Update the $settings array to your list of number of days => ''.
* Read the Add On documentation for additional customization using this filter.
*/
function custom_pmproeewe_email_frequency( $settings = array() ) {
@femiyb
femiyb / pmpro-customizations.php
Created August 19, 2021 10:41 — forked from travislima/pmpro-customizations.php
PMPro-extra-expiration-warning-emails (Change day email is sent out)
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
<?php
/*
* Display Member Number on Edit Profile Page for Admin
*
*/
// We have to put everything in a function called on init, so we are sure Register Helper is loaded.
function my_pmprorh_init_member_number() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
@femiyb
femiyb / assign_pmpro_level_to_role.php
Last active August 3, 2021 12:31
Assign a LEVEL to a unique role with Expiration Date
<?php
/**
* Assign a LEVEL to a unique role with Expiration Date
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@femiyb
femiyb / shop_manager_show_admin_bar.php
Created August 2, 2021 14:30
Give Shop Managers access to dashboard
<?php
/**
* This will Give WooCommerce Sho[p Managers access to the dashboad of you are removing access for other users
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function shop_manager_show_admin_bar() {
if(current_user_can('shop_manager')) {
add_filter( 'show_admin_bar', '__return_true' );
}
}