Skip to content

Instantly share code, notes, and snippets.

@webdados
Created February 14, 2024 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdados/8db7a3aa5e86bd971c747576003d89d7 to your computer and use it in GitHub Desktop.
Save webdados/8db7a3aa5e86bd971c747576003d89d7 to your computer and use it in GitHub Desktop.
Filter to override/set the service cost on runtime on the Product Assembly / Gift Wrap / … Cost for WooCommerce plugin
<?php
/* Set the product assembly cost to 5 on two specific products - https://wordpress.org/plugins/product-assembly-cost/ */
add_filter( 'product_assembly_cost', function( $cost, $product_or_variation ) {
if ( $product_or_variation->get_id() == 17536 || $product_or_variation->get_id() == 16932 ) { // Set whatever condition you want here
$cost = 5;
}
return $cost;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment