1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. Product Page
  5. Change position of add-on fields
  1. Home
  2. Knowledge Base
  3. WooCommerce Product Add-Ons Ultimate
  4. Change position of add-on fields
  1. Home
  2. Knowledge Base
  3. Advanced Topics for Add-Ons Ultimate
  4. Change position of add-on fields

Change position of add-on fields

The add-on fields need to be positioned within the WooCommerce add to cart form on the product page. This is so their values can be captured when a user adds the product to the cart.

By default, they’re positioned before the add to cart button. However, you can move them to below the add to cart button using this snippet:

<?php
/**
* Move add-on fields below the add to cart button
*/
function tester_remove_fields_from_before_button() {
remove_action( 'woocommerce_before_add_to_cart_button', 'pewc_product_extra_fields' );
add_action( 'woocommerce_after_add_to_cart_button', 'pewc_product_extra_fields' );
}
add_action( 'init', 'tester_remove_fields_from_before_button' );

You can find out how to add a snippet here.

Moving the fields elsewhere on the page

The add-on fields are part of the WooCommerce cart form on the product page. These means that the data from the fields can be passed to WooCommerce when the user adds the product to the cart.

For this reason, it’s not easily possible to move the fields elsewhere on the product page.

Was this article helpful?

Related Articles