Ecommerce Shopify WordPress Discussion

ACF value display in checkout and order summary

I need your assistance. I wrote the following code add_action( 'woocommerce_single_product_summary', 'show_vin', 30 ); function show_vin() { global $product; $arithmos_plaisiou = get_field( "arithmos_plaisiou" ); if ( $product && has_term( 'antallaktika', 'product_cat', $product->get_id() ) ) { ?> <div class="show_ask_vin"> <label id="vin_label" for="vin_input">*Αριθμός πλαισίου οχήματος:</label> <input type="text" id="vin_input" name="vin_input" value="<?php echo esc_attr($arithmos_plaisiou); ?>"> </div> <script> jQuery(function($) { // Attach a submit event handler to the add-to-cart form $('form.cart').submit(function() { // Get the value of the VIN input field and trim any leading or trailing whitespace var vinValue = $('#vin_input').val().trim(); // Check if the VIN input length is exactly 17 characters if (vinValue.length !== 17) { // If it's not 17 characters, prevent the form submission and display an error message alert('Παρακαλώ εισάγετε τον αριθμό πλαισίου 17 ψηφίων! '); return false; // Prevent form submission } // Add the VIN value to the cart item data $('input[name="vin_input"]').val(vinValue); // If the VIN input length is 17 characters, allow the form submission return true; }); }); </script> <?php }} to add an ACF to single product page to ask for VIN number of a car when product meets a certain category. I want to pass the value of the ACF field to woocommerce order summary. I tried some solution i found but none of them worked. Tried the following snippets // Save VIN value to cart item data add_filter('woocommerce_add_cart_item_data', 'save_vin_to_cart', 10, 2); function save_vin_to_cart($cart_item_data, $product_id) { if (isset($_POST['vin_input'])) { $cart_item_data['vin_input'] = sanitize_text_field($_POST['vin_input']); } return $cart_item_data; } // Display VIN value in cart add_filter('woocommerce_get_item_data', 'display_vin_in_cart', 10, 2); function display_vin_in_cart($item_data, $cart_item) { if (!empty($cart_item['vin_input'])) { $item_data[] = array( 'key' => 'VIN', 'value' => $cart_item['vin_input'] ); } return $item_data; }
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.