Skip to content

Instantly share code, notes, and snippets.

View jobthomas's full-sized avatar

Job jobthomas

View GitHub Profile
@jobthomas
jobthomas / formgradients.scss
Last active September 1, 2018 20:09
Gradient change for form elements
$color: #804A69;
/*-------
Goal: The main color gets lighten by a small percentage each time the nth-of-type increase
-------*/
form { // to limit to forms only
$n: 15; // to make sure the loop stops
@for $i from 0 to $n { // for loop
$label: $i/10 * 100% - 10%; // e.g. for nth-of-type(1) $i = 3 -> $label = (3/10 * 100%) - 10% = 20%

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:
@jobthomas
jobthomas / functions.php
Last active July 31, 2017 13:00 — forked from mikejolley/functions.php
WooCommerce - Adjust the default quantity
// Simple products
add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 );
function jk_woocommerce_quantity_input_args( $args, $product ) {
if ( is_singular( 'product' ) ) {
$args['input_value'] = 2; // Starting value (we only want to affect product pages, not cart)
}
return $args;
}