Skip to content

Instantly share code, notes, and snippets.

Avatar

Wil Brown DeveloperWil

View GitHub Profile
@DeveloperWil
DeveloperWil / wilbrown-com-custom-login-page.php
Created May 11, 2022
WilBrown.com custom login page, two column, responsive
View wilbrown-com-custom-login-page.php
function wb_login_head(){
?>
<style>
#login{
width:50%;
float:left;
}
#wbd-login-left{
width:50%;
float: right;
@DeveloperWil
DeveloperWil / stripe-send-shipping-billing-address.php
Created Nov 15, 2021
Send shipping or billing address to Stripe transaction
View stripe-send-shipping-billing-address.php
/**
* Send shipping or billing details to Stripe (required by some 3DSecure transactions/currencies)
*
* @param $post_data
* @param $order
*
* @return mixed
*/
function zpd_add_shipping_to_stripe( $post_data, $order ) {
@DeveloperWil
DeveloperWil / gravity-forms-submission-to-amazon-echo.php
Created Apr 29, 2021
Gravity Forms: Form Submission to Amazon Echo
View gravity-forms-submission-to-amazon-echo.php
function gf_alexa_notification( $entry, $form ){
$notifyme_api_url = 'https://api.notifymyecho.com/v1/NotifyMe';
$notifyme_api_secret = '1234567890';
if( $form->ID === 12 ){
// Only for form ID=12
$firstname = rgar( $entry, '1.3' );
$lastname = rgar( $entry, '1.3' );
$phone = rgar( $entry, '2' );
$notification = $firstname . ' ' . $lastname . ' requested a callback on "' . $phone .'"';
@DeveloperWil
DeveloperWil / woocommerce-order-notification-to-amazon-echo.php
Last active Apr 29, 2021
WooCommerce: Order Notification to Amazon Echo
View woocommerce-order-notification-to-amazon-echo.php
function zpd_wc_order_to_alexa( $payload, $resource, $resource_id, $id){
if( $id == 1) { // webhook ID is 1
// Get an instance of the WC_Order object (same as before)
$order = wc_get_order( $resource_id );
$payload[ 'accessCode' ] = ZPD_NOTIFYME_SECRET_API_KEY;
$payload[ 'notification'] = 'There is a new ' . $order->get_status() . ' order';
$payload[ 'notification'] .= ' on the ' . get_bloginfo( 'name' ) . ' website';
$payload[ 'notification'] .= ' from ' . $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() . '.';
}
@DeveloperWil
DeveloperWil / woocommerce-order-data-object-fields
Last active Apr 21, 2021
WooCommerce: Order data object fields
View woocommerce-order-data-object-fields
<?php
/**
* See https://woocommerce.github.io/code-reference/classes/WC-Order.html#property_data for all data items in the WC_Order
*/
/**
* This line is not needed within the filter as $order is passed as a parameter
*/
$order_data = $order->get_data();
@DeveloperWil
DeveloperWil / woocommerce-stripe-product-customer-metadata
Created Mar 30, 2021
WooCommerce: Stripe product and customer metadata
View woocommerce-stripe-product-customer-metadata
/**
* Add Stripe metadata along with WooCommerce purchase
*
* @param $metadata
* @param $order
* @param $source
* @return mixed
*/
function wbdc_filter_wc_stripe_payment_metadata( $metadata, $order, $source ) {
@DeveloperWil
DeveloperWil / woocommerce-global-redirect-after-payment.php
Created Mar 29, 2021
WooCommerce: Global redirect after payment
View woocommerce-global-redirect-after-payment.php
/* Redirect user after check out */
function zpd_wc_global_redirect_after_payment() {
global $wp;
$redirect_url = 'https://yourdomain.com/this-page/';
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( $redirect_url );
exit;
}
@DeveloperWil
DeveloperWil / sql-view-wordpress-autoloaded-data.sql
Created Mar 24, 2021
WordPress: View Database Autoloaded Data
View sql-view-wordpress-autoloaded-data.sql
SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes'
UNION
SELECT 'autoloaded data count', count(*) FROM wp_options WHERE autoload='yes'
UNION
(SELECT option_name, length(option_value) FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10);
@DeveloperWil
DeveloperWil / woocommerce-set-minimum-checkout-order-amount.php
Created Mar 9, 2021
WooCommerce: Set a minimum amount at checkout
View woocommerce-set-minimum-checkout-order-amount.php
/**
* Set a minimum amount for checkout
*/
function zpd_wc_minimum_order_amount(): void {
/**
* $minimum is the minimum value you want to set the checkout total order amount.
*/
$minimum = 50;
/**
@DeveloperWil
DeveloperWil / woocommerce-change-shop-page-order-by
Last active Mar 8, 2021
WooCommerce: Set default order on shop page to by price, title or date
View woocommerce-change-shop-page-order-by
/**
* Change the default shop page 'catalogue' order of how products are displayed
*
* You can use the following parameters:
* 'menu_order' – by the custom order first, then by product name (Default)
* 'popularity' – by the number of sales
* 'rating' – by the average rating
* 'date' – recently added products will be displayed first
* 'price' – cheapest products will be displayed first
* 'price-desc' – the most expensive first