Skip to content

Instantly share code, notes, and snippets.

View melvinstanly's full-sized avatar
🌪️
Fast and Furious

Melvin Stanly melvinstanly

🌪️
Fast and Furious
View GitHub Profile
@junaidtk
junaidtk / Enable Xdebug in MAC
Created November 21, 2019 04:59
Formatting the var_dump in MAMP
This is used to formate the debuging mode of the MAMP.
Here we need to enable the xdebug module in mamp in php ini file.
There are two different php ini file in, The locations are following.
/Applications/MAMP/bin/php/php7.3.8/conf/php.ini ---- In bin folder
/Applications/MAMP/conf/php7.3.8/php.ini ---- In conf folder
In bin folder open php.ini file and uncomment the line
zend_extension="/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
@madeincosmos
madeincosmos / functions.php
Created May 23, 2019 10:11
Add customer username and ID to WooCommerce emails
add_filter( 'woocommerce_email_customer_details_fields', 'add_user_id_to_woocommerce_emails', 10, 3);
function add_user_id_to_woocommerce_emails( $fields, $sent_to_admin, $order ) {
$user_id = $order->get_customer_id();
$user_info = get_userdata( $user_id );
$fields['user_id'] = array(
'label' => __( 'User ID', 'woocommerce' ),
'value' => $user_id
);
@damiencarbery
damiencarbery / conditional-wc-email-sending.php
Last active July 30, 2023 07:32
Conditionally send WooCommerce emails: Dynamically determine whether to send a WooCommerce email. https://www.damiencarbery.com/2018/12/conditionally-disable-woocommerce-emails/
<?php
/*
Plugin Name: Conditionally send WooCommerce emails
Plugin URI: https://www.damiencarbery.com/2018/12/conditionally-disable-woocommerce-emails/
Description: Dynamically determine whether to send a WooCommerce email.
Author: Damien Carbery
Version: 0.2
*/
// The filter name is 'woocommerce_email_enabled_'.WC_Email::id e.g. 'new_order', 'cancelled_order' etc
@abhianair
abhianair / application.js
Last active December 4, 2018 04:34
Update Country code field upon selecting Country field using AJAX
$(document).ready(function(){
$("#id_country_code").change(function(){
var option = $(this).val();
$.ajax({
type: "GET",
url: "/models/get",
data:{
key: option
},
success: function(response){
@sarathlal-old
sarathlal-old / Gmail SMTP & WordPress
Last active April 4, 2019 05:26
Configure Gmail account & SMTP plugin to send SMTP emails from WordPress
1. Install SMTP Plugins
https://wordpress.org/plugins/search/SMTP/
2. Configure Plugins
* Outgoing Mail (SMTP) Server: smtp.gmail.com
* Use Authentication: Yes
* Use Secure Connection: Yes (TLS or SSL)
* Username: your Gmail account (e.g. user@gmail.com)
@tankbar
tankbar / functions-trustpilot.php
Created March 21, 2018 10:39
Trustpilot AFS product tracking in order confirmation mail for WooCommerce
add_action( 'woocommerce_email_after_order_table', 'add_trustpilot_afs_tracking', 20, 2 );
function add_trustpilot_afs_tracking( $order, $sent_to_admin ) {
if ( ! $sent_to_admin ) {
?>
<script type="application/json+trustpilot">
{
"recipientEmail": "<?php echo $order->billing_email; ?>",
"recipientName": "<?php echo $order->billing_first_name.' '. $order->billing_last_name; ?>",
"referenceId": "<?php echo $order->get_order_number(); ?>",
"products": [<?php
@Bobz-zg
Bobz-zg / woo-checkout.php
Last active April 12, 2023 01:41
Pre-populate Woocommerce checkout fields
<?php
/**
* Pre-populate Woocommerce checkout fields
* Note that this filter populates shipping_ and billing_ fields with a different meta field eg 'first_name'
*/
add_filter('woocommerce_checkout_get_value', function($input, $key ) {
global $current_user;
switch ($key) :
@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
@mikejolley
mikejolley / gist:1604009
Created January 13, 2012 00:31
WooCommerce - Add a special field to the checkout, order emails and user/order meta
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**