Skip to content

Instantly share code, notes, and snippets.

View Preciousomonze's full-sized avatar
🤡
Coding on the bicycle 😎🚴🏽‍♂️

Precious Omonzejele Preciousomonze

🤡
Coding on the bicycle 😎🚴🏽‍♂️
View GitHub Profile
@Preciousomonze
Preciousomonze / pekky-wc-file.php
Last active May 9, 2022 14:15
Disable WooCommerce Product variation dropdown. Copy code and put in your child theme's function.php or anywhere you see fit. Use at your risk, enjoy! I mean, what's life without taking risks? 🚀
<?php
/**
* Disable variation dropdown.
*
* Adds the disable attribute to the select tag.
*
* @param string $html
* @param array $args
* return string
*/
@Preciousomonze
Preciousomonze / pekky-wc-change-out-of-stock-text.php
Last active May 12, 2022 17:31
This MU-Plugin helps change "out of stock" text to what you want either on single product page or loop page, or both. make sure you edit the $out_of_stock_span_class to your use case. Use at your risk, enjoy! I mean, what's life without taking risks? 🚀 Inspired by: https://woocommercecommunity.slack.com/archives/CV9AF72PR/p1651253141682729
<?php
/**
* WooCommerce Change "out of stock" text.
*
* @package pekky-wc-change-out-of-stock-text
* @author Precious Omonzejele (CodeXplorer 🤾🏽‍♂️🥞🦜🤡)
*
* @wordpress-plugin
* Plugin Name: WooCommerce Change "out of stock" text
* Plugin URI: https://gist.github.com/Preciousomonze/c0d49effe8e3d613f838aa35f352bfc9
@Preciousomonze
Preciousomonze / pekky-wc-change-session-country-state.php
Last active May 7, 2022 21:43
This MU-Plugin helps preset or preselect a country/state based on checkout. It can be shipping or billing. All you need to do is call the function 'CLASS::process_selected_country_or_state_etc('NG')' to set the value. Inspired by https://wordpress.org/support/topic/change-session-shipping-country-on-product-page-collection-page-2/ . Use at your …
<?php
/**
* WooCommerce Change Session Country/State for checkout.
*
* @package pekky-wc-change-session-country-state
* @author Precious Omonzejele (CodeXplorer 🤾🏽‍♂️🥞🦜🤡)
*
* @wordpress-plugin
* Plugin Name: WooCommerce Change Session Country/State for checkout
* Plugin URI: https://gist.github.com/Preciousomonze/58a1e85557a74a4094f245adb0f8786f
@Preciousomonze
Preciousomonze / cross-sells.php
Last active October 26, 2021 11:55
Display cross sells of a particular product in a cart. Add the file to your child theme: 'woocommerce/cart/' folder.
<?php
/**
* Cross-sells
*
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cross-sells.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@Preciousomonze
Preciousomonze / custom_functions.php
Last active August 8, 2021 18:05
Contact form 7 file upload to pmpro registration helper plugin - usecase is when adding a user via cf7, and a file upload is also supported. I had to readjust my actual code to fit for this example, so it might be rough 🤗. by the way, this stressed me out. hope i could solve your problem.
<?php
/**
* Upload our file to pmpro helper side.
*
* @param array $cf7_uploads
* @return bool false if file isnt set, true otherwise, just vibess.
*/
function pekky_upload_cf7_file_to_pmp_temp( $cf7_uploads ) {
if ( ! is_array( $cf7_uploads ) ) {
@Preciousomonze
Preciousomonze / Readme.md
Last active June 12, 2024 09:15
Paid Membership Pro - How to get some functions you might not see in the documentation. happened to me a lot 😁

So I'll just try to be dumping some things here for docu purposes. Feel free to comment, if you have more to add. I'll try as much as possible to update.

Disclaimer: Please remember that we are all imperfect, and as such, some of the info here might be or outdated or incomplete, that's why we're a community. Any info you find incorrect, please do well to suggest the correct thing in the comment section, we're doing it for all of us. People powerrr

Note: That this also includes functions from their addons.

Format will be "Function name - Plugin name"

pmprorh_getProfileFields - Paid Membership Pro Registration Helper

Guess this helps get the fields from the profile.

@Preciousomonze
Preciousomonze / frontend.js
Created July 29, 2021 09:16
Temporary fix: conflict with some themes (JS error - Uncaught SyntaxError) #40: https://https://github.com/Preciousomonze/woocommerce-phone-validator/issues/40
jQuery( document ).ready( function( $ ){
// set phone number properly for intl
// here, the index maps to the error code returned from getValidationError
var wcPvPhoneErrorMap = wcPvJson.validationErrors;
// start
if ($( '.wc-pv-intl input' ).length == 0) {// add class, some checkout plugin has overriden my baby
$( '#billing_phone_field' ).addClass( 'wc-pv-phone wc-pv-intl' );
}
// Set default country.
var wcPvDefCountry = ( wcPvJson.defaultCountry == '' ? $( `${wcPvJson.parentPage} #billing_country` ).val() : wcPvJson.defaultCountry );
@Preciousomonze
Preciousomonze / custom.php
Last active April 14, 2021 13:52
Cache-bust all scripts/styles
<?php
/**
* Cache-bust all scripts/styles. form helgatheviking
*
* Can go to your functions.php.
* Useful for development purposes.
* Special thanks to HelgaTheViking.
*/
function pekky_add_timestamp_css_js( $src ) {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
@Preciousomonze
Preciousomonze / code.php
Last active November 11, 2020 15:26
Add a dynamic fee to meet up to your minimum total allowed for your store. This is useful incase you want the user to order from your store, but want a minimum cart total price, and at the same time if the cart total is less than your minimum price, you dynamically add what's left to meet the minimum price: more info here: https://woocommercecom…
/**
* Helps sort extra fee to meet minimum total.
*/
function pekky_sort_extra_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
$minimum_price = 20; // The minimum price you allow for a user to be able to place order.
@Preciousomonze
Preciousomonze / pekky-catalog-snippet.php
Created October 8, 2020 13:49
Alter WooCommerce Product Catalog visibility via hook. Based on this thread here: https://woocommercecommunity.slack.com/archives/C1KAZ91E3/p1601981478254000
<?php
/**
* Change catalog visibility.
*
* No need to run ::save(), cause this hook is run before $product->save()
*
* Hooked to woocommerce_admin_process_product_object
*
* @param WC_Product $product The product object.
*/