Created
November 2, 2022 15:14
-
-
Save wbaxterh/e34403249a2ea7af2237d257779b5ea8 to your computer and use it in GitHub Desktop.
Pass Woocommerce Product Data to Contact Form 7
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
// add the action | |
add_action( 'woocommerce_product_meta_end', 'action_woocommerce_after_add_to_cart_form'); | |
// define the woocommerce_after_add_to_cart_form callback | |
function action_woocommerce_after_add_to_cart_form( ) { | |
global $product; | |
$productId = $product->get_id(); | |
$productName = $product->get_name(); | |
// make action magic happen here... | |
echo '</div></div><div id="beforeContact" class="container w-100 p-2" style="clear: both;"></div>'; | |
echo '<div class="container product-contact-container m-0 w-100 bg-gradient text-light" id="pc-'.$productId.'"> | |
<div class="row"> | |
<div class="col-md d-block mx-auto text-center">'; | |
echo "<h2 class='mt-4 p-2 pb-0 mb-0'>Contact us to Order</h2>"; | |
echo "<h5 class='p-2 pt-0'>".$productName."</h5>"; | |
$text='[contact-form-7 id="326" product="'.$productName.'" title="Product Page Contact Form"]'; | |
echo do_shortcode( $text ); | |
echo '</div> | |
</div> | |
</div>'; | |
echo "<div class='summary entry-summary'>"; | |
echo "<div class='product_meta'>"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment