Skip to content

Instantly share code, notes, and snippets.

@marcusig
Created January 28, 2022 09:56
Show Gist options
  • Save marcusig/4f8f860ceb10467a5e2db21203fda00e to your computer and use it in GitHub Desktop.
Save marcusig/4f8f860ceb10467a5e2db21203fda00e to your computer and use it in GitHub Desktop.
Remove configurable product from the cart
<?php
add_action( 'mkl_pc/added_linked_product_to_the_cart', function( $cart_item_key, $product_id ) {
WC()->cart->remove_cart_item( $cart_item_key );
// Add custom notice
wc_add_notice( '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'View cart', 'woocommerce' ) . '</a>' . __(' Your dress design has been added to your cart.', 'product-configurator-custom-theme') );
// Prevent default notice
throw new Exception();
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment