I want to add a custom field "Product Description" on a specific set woocommerce products in functions.php. See below code:
add_action('woocommerce_before_add_to_cart_button','wdm_add_custom_fields');
function wdm_add_custom_fields( $cart ) {
global $product;
ob_start();
?>
<div class="wdm-custom-fields">
<label>Product Description</label>: <input type="text" name="wdm_name">
</div>
<div class="clear"></div>
<?php
$content = ob_get_contents();
$targeted_ids = array(29, 27, 28, 72, 84, 95);
ob_end_flush();
foreach ( $cart->get_cart() as $item ) {
if ( array_intersect($targeted_ids, array($item['product_id'], $item['variation_id']) ) );
}
return $content;
}
I don't know what went wrong with the code as Wordpress gives "There has been a critical error on this website." Notice. I turned on WordPress Error Reporting in wp-config.php file but it didn't display any errors.
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
Perhaps the if statement isn't working. Please advise.