Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created July 1, 2019 15:52
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 mgibbs189/2fab02d1262a0eeec750f7c140874a84 to your computer and use it in GitHub Desktop.
Save mgibbs189/2fab02d1262a0eeec750f7c140874a84 to your computer and use it in GitHub Desktop.
Layout builder - WooCommerce "add to cart" button
<?php
// Add the following to custom-hooks.php or into your (child) theme's functions.php
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
if ( 'add-to-cart' == $item['settings']['name'] ) {
global $post;
$value = do_shortcode( '[add_to_cart id="' . $post->ID . '"]' );
}
return $value;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment