Skip to content

Instantly share code, notes, and snippets.

View corsonr's full-sized avatar

Remi Corson corsonr

View GitHub Profile
@corsonr
corsonr / index.html
Created January 3, 2018 12:36
Basic grid layout
<html>
<header>
<link rel='stylesheet' id='style-css' href='style.css' type='text/css' media='all' />
</header>
<body>
<section id="page">
<header>Header</header>
<section id="intro">Intro</section>
<main>Main section</main>
@corsonr
corsonr / functions.php
Created December 22, 2017 08:17
WooCommerce: disable payments on checkout page
<?php // Do not include this if already open! Code goes in theme functions.php.
// Disable all payment gateways on the checkout page and replace the "Pay" button by "Place order"
add_filter( 'woocommerce_cart_needs_payment', '__return_false' );
@corsonr
corsonr / functions.php
Created December 18, 2017 11:12
WooCommerce: replace "tax" in "includes $xx.xx Tax" on the cart page
<?php // Do not include this if already open! Code goes in theme functions.php.
/**
* woocommerce_cart_totals_order_total_html
*
* @access public
* @since 1.0
* @return void
*/
add_filter( 'woocommerce_cart_totals_order_total_html', 'woo_rename_tax_inc_cart', 10, 1 );
@corsonr
corsonr / functions.php
Last active February 4, 2019 21:48
WooCommerce custom emails header
<?php // Do not include this if already open! Code goes in theme functions.php.
add_filter( 'woocommerce_email_headers', 'woo_update_emails_header', 10, 2);
function woo_update_emails_header( $headers, $object ) {
$headers = array();
$headers[] = 'Content-Type: text/html; charset=UTF-8'; // update the encoding/charset here
return $headers;
}
@corsonr
corsonr / functions.php
Created December 5, 2017 08:37
WooCommerce: modify WooCommerce default customer role
<?php // Do not include this if already open! Code goes in theme functions.php.
/**
* woocommerce_custom_new_customer_data
*
* @access public
* @since 1.0
* @return void
*/
function woocommerce_custom_new_customer_data( $new_customer_data ) {
@corsonr
corsonr / functions.php
Created November 6, 2017 07:58
Woo: force user role after order is placed
<?php // Do not include this if already open! Code goes in theme functions.php.
function woo_force_update_user_role( $order_id ) {
$order = new WC_Order( $order_id );
if ( $order->user_id > 0 ) {
$user = new WP_User( $order->user_id );
@corsonr
corsonr / stripe.php
Created October 16, 2017 07:20
WooCommerce: version check support complete
<?php
/*
* Plugin Name: WooCommerce Stripe Gateway
* Plugin URI: https://wordpress.org/plugins/woocommerce-gateway-stripe/
* Description: Take credit card payments on your store using Stripe.
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* Version: 3.2.3
* Requires at least: 4.4
* Tested up to: 4.8
@corsonr
corsonr / stripe.php
Last active October 4, 2022 11:30
WooCommerce: version support check
* WC requires at least: 3.0.0
* WC tested up to: 3.2.0

Brands REST API

The Brands REST API allows you to create, view, update, and delete individual, or a batch, of brands. The endpoint is /wp-json/wc/v1/products/brands which basically mimics /wp-json/wc/v1/products/categories. You can refer to the same documentation of product categories REST API.

In addition to /products/brands endpoints, the /products endpoints also updated to display brands in the response and check the JSON request for brands.

Examples

  • Retrieve all product brands:
@corsonr
corsonr / functions.php
Created May 31, 2017 09:14
WooCommerce: move Apple Pay button below customer details form
<?php // Do not include this if already open! Code goes in theme functions.php.
/*
* Removes Apple Pay button on the checkout page.
*/
remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Apple_Pay::instance(), 'display_apple_pay_button' ), 1 );
remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Apple_Pay::instance(), 'display_apple_pay_separator_html' ), 2 );
/*
* Adds Apple Pay button on the checkout page, below customers details, and inverse button/separator order.