Skip to content

Instantly share code, notes, and snippets.

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

RwkY rwkyyy

🏠
Working from home
View GitHub Profile
@rwkyyy
rwkyyy / Popup Maker - at 3 pages popup
Last active June 4, 2016 19:19 — forked from anonymous/Popup Maker - at 3 pages popup
Simle jQuery to show a popup at 3rd page of a visitor - Wordpress Popup Maker
jQuery(document).ready(function ($) {
{
var visited = Cookies.get('visited');
if (visited == undefined) {
Cookies.set('visited', 0, {path: '/'});
}
else if (visited < 2) {
Cookies.set('visited', ++visited, {path: '/'});
}
else if (visited == 2) {
@rwkyyy
rwkyyy / EVD Cart Discount Rules
Last active February 2, 2022 18:14
WooCommerce conditional subtotal cart discounts
<?php
/**
* Plugin Name: EVD - Card Discount Rules
* Plugin URI: https://rwky.ro
* Description: Discount rules for cart
* Version: 1.0
* Author: Eduard Vasile Doloc
* Author URI: http://rwky.ro
* Developer: Eduard Vasile Doloc
* Developer URI: http://rwky.ro
@rwkyyy
rwkyyy / gist:59a9bbe84e667fcadd60c416f6f051c0
Created May 18, 2018 12:25
Display free shipping in product loop
add_action( 'woocommerce_after_shop_loop_item_title', 'loc_show_free_shipping_badge' );
function loc_show_free_shipping_badge() {
global $post, $product;
if ( $product && $product->get_price() >= 100 ) {
echo '<span class="free-shipping">' . __( 'Livrare Gratuită!' ) . '</span>';
}
}
@rwkyyy
rwkyyy / gist:d3552815ecefde3aeb93c1f0a0953f34
Created May 30, 2018 13:00
WooCommerce - Add static content after product title
function add_after_product_title_rwk() {?>
<p class="small"><?php echo 'hello world'; ?></p>
<?php }
add_action( 'woocommerce_single_product_summary', 'add_after_product_title_rwk', 6 );
@rwkyyy
rwkyyy / gist:ed5386b829a9aa6849aca1f452df10b4
Created June 13, 2018 12:38
send canceled order mail to client - woocommerce
/*
* Add customer email to Cancelled Order recipient list
*/
function wc_cancelled_order_add_customer_email( $recipient, $order ){
return $recipient . ',' . $order->billing_email;
}
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
@rwkyyy
rwkyyy / gist:0a7e6a3fd39a5ad640f190164d699e91
Created August 2, 2018 14:57
Redirect WooCommerce for non-logged-in
function rwk_redirect_b2b() {
if (
! is_user_logged_in()
&& (is_woocommerce() || is_cart() || is_checkout())
) {
// feel free to customize the following line
wp_redirect( site_url('autentificare/') )
exit;
}
}
@rwkyyy
rwkyyy / gist:80254548374ffeab7a95bec03e37f7c6
Created September 21, 2018 09:14
Show number of failed orders
add_action( 'woocommerce_admin_order_data_after_order_details', 'failed_orders_evd', 10, 2 );
function failed_orders_evd( $order ) {
$customer_orders = get_posts( array(
'numberposts' => -1,
// 'meta_key' => '_customer_user',
'meta_value' => $order->get_billing_email(),
'post_type' => 'shop_order',
'post_status' => array('wc-failed'),
) );
@rwkyyy
rwkyyy / gist:8cad5438e4f80293e2b23034c13fe955
Last active September 22, 2018 14:31
clean orphaned _postmeta
select post_id from wprh_postmeta pm where pm.post_in not in (select ID from wprh_posts)
@rwkyyy
rwkyyy / gist:d43053675af6cfa89eda0d9d505865ee
Created October 15, 2018 09:13
remove the damn notices for non-admin.
// remove admin notices except admin
add_action('admin_head', function() {
if(!current_user_can('manage_options')){
remove_action( 'admin_notices', 'update_nag', 3 );
remove_action( 'admin_notices', 'maintenance_nag', 5 );
echo "<style>.notice, .update-nag , .error, .updated{ display:none!important; }</style>";
}
});
@todo: find all actions and remove them and if it's not enough, CSS will do the trick!
@rwkyyy
rwkyyy / gist:a138c27bcbaccac631fe6282f0ecc29c
Last active February 24, 2021 10:02
Show the order phone number in the woocommerce order list
// add the column, we need to display it, right?
function wc_order_extras_column_evd( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'order_total' === $column_name ) {
$new_columns['order_phone'] = __( 'Phone no.', 'rwky_ro' );
}
}
return $new_columns;