Skip to content

Instantly share code, notes, and snippets.

@nielslange
Last active July 18, 2023 17:19
Show Gist options
  • Save nielslange/7d827ff3a1e446cf2f347fddd5abe7e6 to your computer and use it in GitHub Desktop.
Save nielslange/7d827ff3a1e446cf2f347fddd5abe7e6 to your computer and use it in GitHub Desktop.

Revisions

  1. nielslange revised this gist Jul 18, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion snippet.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    const { registerCheckoutFilters } = window.wc.blocksCheckout;

    // Adjust cart item class of the cart line items.
    // 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.
  2. nielslange created this gist Jul 18, 2023.
    13 changes: 13 additions & 0 deletions snippet.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const { registerCheckoutFilters } = window.wc.blocksCheckout;

    // Adjust cart item class of the cart line 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;
    }
    return 'my-custom-class';
    }
    } );