Created
July 1, 2019 15:52
-
-
Save mgibbs189/2fab02d1262a0eeec750f7c140874a84 to your computer and use it in GitHub Desktop.
Layout builder - WooCommerce "add to cart" button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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