Skip to content

Instantly share code, notes, and snippets.

View nielslange's full-sized avatar
👨‍💻
Moving bits and bytes around the globe

Niels Lange nielslange

👨‍💻
Moving bits and bytes around the globe
View GitHub Profile
/**
* External dependencies
*/
import {
createContext,
useContext,
useReducer,
useRef,
useMemo,
@nielslange
nielslange / index.js
Last active July 19, 2023 09:39
ExperimentalOrderLocalPickupPackages
/**
* External dependencies
*/
import { registerPlugin } from '@wordpress/plugins';
import { ExperimentalOrderLocalPickupPackages } from '@woocommerce/blocks-checkout';
const render = () => {
return (
<ExperimentalOrderLocalPickupPackages>
<div>
@nielslange
nielslange / index.js
Last active July 19, 2023 09:39
ExperimentalDiscountsMeta
/**
* External dependencies
*/
import { registerPlugin } from '@wordpress/plugins';
import { ExperimentalDiscountsMeta } from '@woocommerce/blocks-checkout';
const render = () => {
return (
<ExperimentalDiscountsMeta>
<div class="wc-block-components-totals-wrapper">
@nielslange
nielslange / index.js
Last active July 19, 2023 09:39
ExperimentalOrderShippingPackages
/**
* External dependencies
*/
import { registerPlugin } from '@wordpress/plugins';
import { ExperimentalOrderShippingPackages } from '@woocommerce/blocks-checkout';
const render = () => {
return (
<ExperimentalOrderShippingPackages>
<div>
@nielslange
nielslange / index.js
Last active July 19, 2023 09:39
ExperimentalOrderMeta
/**
* External dependencies
*/
import { registerPlugin } from '@wordpress/plugins';
import { ExperimentalOrderMeta } from '@woocommerce/blocks-checkout';
const render = () => {
return (
<ExperimentalOrderMeta>
<div class="wc-block-components-totals-wrapper">
@nielslange
nielslange / snippet.js
Created July 18, 2023 17:25
Coupons filter » coupons
const { registerCheckoutFilters } = window.wc.blocksCheckout;
// Replace coupon label for matching coupon(s).
registerCheckoutFilters( 'example-extension', {
coupons: ( coupons ) => {
return coupons.map( ( coupon ) => {
// Regex to match autocoupon then unlimited undersores and numbers
if ( ! coupon.label.match( /autocoupon(?:_\d+)+/ ) ) {
return coupon;
}
@nielslange
nielslange / snippet.js
Created July 18, 2023 17:19
Order Summary Items filter » subtotalPriceFormat
const { registerCheckoutFilters } = window.wc.blocksCheckout;
// Adjust subtotal price format of the order summary items.
registerCheckoutFilters( 'example-extension', {
subtotalPriceFormat: ( value, extensions, args ) => {
// Return early since this filter is not being applied in the Summary context.
// We must return the original value we received here.
if ( args?.context !== 'summary' ) {
return value;
}
@nielslange
nielslange / snippet.js
Last active July 18, 2023 17:19
Order Summary Items filter » cartItemClass
const { registerCheckoutFilters } = window.wc.blocksCheckout;
// Adjust cart item class of the order summary items.
registerCheckoutFilters( 'example-extension', {
cartItemClass: ( value, extensions, args ) => {
// Return early since this filter is not being applied in the Summary context.
// We must return the original value we received here.
if ( args?.context !== 'summary' ) {
return value;
}
@nielslange
nielslange / snippet.js
Created July 18, 2023 17:07
Order Summary Items filter » cartItemPrice
const { registerCheckoutFilters } = window.wc.blocksCheckout;
// Adjust cart item price of the order summary items.
registerCheckoutFilters( 'example-extension', {
cartItemPrice: ( value, extensions, args ) => {
// Return early since this filter is not being applied in the Summary context.
// We must return the original value we received here.
if ( args?.context !== 'summary' ) {
return value;
}
@nielslange
nielslange / snippet.js
Last active July 18, 2023 17:06
Order Summary Items filter » itemName
const { registerCheckoutFilters } = window.wc.blocksCheckout;
// Adjust item name of the order summary items.
registerCheckoutFilters( 'example-extension', {
itemName: ( value, extensions, args ) => {
// Return early since this filter is not being applied in the Summary context.
// We must return the original value we received here.
if ( args?.context !== 'summary' ) {
return value;
}