Skip to content

Instantly share code, notes, and snippets.

@duplaja
duplaja / convert-guest-to-logged-in.php
Last active May 22, 2019 02:56
Convert Guest Orders to Logged In
<?php
//Runs on User Registration
add_action( 'user_register', 'wc_map_guest_initial_match_past_orders', 10, 1 );
function wc_map_guestinitial_match_past_orders( $user_id ) {
//Get current users's e-mail from ID
$current_user = get_user_by( 'ID', $user_id );
$email = $current_user->user_email;
@aliciaiceland
aliciaiceland / functions.php
Created May 29, 2017 11:33
Pre-populate Woocommerce checkout fields
<?php
/**
* Pre-populate Woocommerce checkout fields
*/
add_filter('woocommerce_checkout_get_value', function($input, $field ) {
global $current_user;
switch ($field) :
case 'billing_first_name':
case 'shipping_first_name':
return $current_user->first_name;
@RiaanKnoetze
RiaanKnoetze / style.css
Created May 29, 2017 07:13
Hide product count/mark next to category titles when using WooCommerce
.woocommerce mark {
display: none;
}
@mohammadmursaleen
mohammadmursaleen / purchased_by_order_column.php
Created May 26, 2017 10:33
WooCommerce - Add purchased by column in order list
<?php
add_filter( 'manage_shop_order_posts_columns', 'show_purchased_by_shop_order_columns' , 100 );
add_action( 'manage_shop_order_posts_custom_column', 'show_purchased_by_render_shop_order_columns', 2 );
add_filter( 'manage_edit-shop_order_sortable_columns', 'show_purchased_by_shop_order_sortable_columns' );
/**
* Define custom columns for orders.
* @param array $columns
* @return array
@dasbairagya
dasbairagya / index.txt
Last active December 6, 2017 10:07
List of necessary codes at a glance.
---List of all gists at a glance---
1)Display WooCommerce Recently viewed products Without a Shortcode.
2)Display WooCommerce Latest Products Without a Shortcode.
3)Add custom columns to the user table of the admin dashbord.
4)front-end to cpt including image(advance).Used in sharespace.
5)short code to get the woocommerce recently viewed products.
6)Show woocommerce featured product in home page.
7)Get the image,title and link of the parent term of product_cat taxonomy in woocommerce for creating the slide in home page with parent category.
8)Woocommerce product-details page common customization.
9)Display an Image Spinner During an Ajax Request.
@vishalck
vishalck / thankyou.php
Created May 23, 2017 14:00
Custom thankyou.php template in WooCommerce
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="woocommerce-order">
<?php if ( $order ) : ?>
@pjrvs
pjrvs / how?
Last active December 9, 2022 18:49
here's the code to populate a mailchimp field with a wordpress variable:
add_filter( 'mailchimp_sync_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber, $user ) {
$subscriber->merge_fields['MERGE6'] = AFF_ID_GOES_HERE;
return $subscriber;
}, 10, 2 );
here's the code to get the aff id:
if ( $affiliate = affiliate_wp()->affiliates->get_by( 'user_id', $user->ID ) ) {
.admin-bar p.demo_store {
top: 28px;
}
p.demo_store {
position: fixed;
top: 0;
left: 0;
right: 0;
margin: 0;
<?php
// Povuci sve lokacije najblize lat i lon koji su prosledjeni
function get_posts_by_geo_distance($post_type,$lat_key,$lng_key,$source_lat,$source_lng) {
global $wpdb;
$sql =<<<SQL
SELECT
rl.ID,
rl.post_title AS location,
ROUND(6371*2*ASIN(SQRT(POWER(SIN(({$source_lat}-abs(lat.lat))*pi()/180/2),2)+
COS({$source_lat}*pi()/180)*COS(abs(lat.lat)*pi()/180)*
@Auke1810
Auke1810 / wpa-clean-header.php
Last active February 25, 2025 22:05
create a clean wordpress header and remove unnecessary clutter.
<?php
/*
Plugin Name: wordpress assist clean header
Plugin URI: http://www.wordpressassist.nl/
Description: Remove shortlink hook
Version: 1.0
Author: AukeJomm
Author URI: http://www.aukejongbloed.nl
*/