Have A Promotional Code Custom Css Woocommerce Move

CSS Programming

When working with WooCommerce, customizing the appearance and functionality of your online store is essential for creating a unique and engaging shopping experience for customers. One common customization is using promotional codes to offer discounts to customers. In this article, I’ll guide you through the process of moving the promotional code field in WooCommerce and adding custom CSS to give it a personalized touch.

Moving the Promotional Code Field

By default, the promotional code field in WooCommerce is located above the “Proceed to Checkout” button on the Cart page. However, you may want to move it for better visibility or to fit the design of your site. To do this, you can use some simple PHP and hooks to reposition the field.

The first step is to create a child theme if you haven’t already. Then, navigate to the functions.php file of your child theme and add the following code:

remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_cart_collaterals', 'woocommerce_checkout_coupon_form', 10 );

This code removes the default action that displays the coupon form and then adds it to another location, in this case, the Cart page sidebar. You can modify the hooks and priority according to your specific layout requirements.

Adding Custom CSS

Once you’ve moved the promotional code field to its new location, you may want to apply custom styling to make it stand out and align with your brand’s aesthetics. This is where custom CSS comes into play.

In your child theme’s directory, create a new CSS file, for example, custom-styles.css. Then, enqueue the file by adding the following code to your child theme’s functions.php:

function enqueue_custom_styles() {
wp_enqueue_style( 'custom-styles', get_stylesheet_directory_uri() . '/custom-styles.css' );
add_action( 'wp_enqueue_scripts', 'enqueue_custom_styles' );

Now you can add your own CSS rules to the custom-styles.css file to style the promotional code field. For example:

/* Custom styles for promotional code field */
.woocommerce-form-coupon-toggle .showcoupon button.button {
background-color: #ff6600;
color: #fff;
border-color: #ff6600;
border-radius: 5px;
padding: 5px 15px;
font-size: 16px;


Customizing the placement and appearance of the promotional code field in WooCommerce can greatly enhance the look and functionality of your online store. By moving the field and adding custom CSS, you have the flexibility to create a seamless and visually appealing shopping experience for your customers. Experiment with different placements and styles to find the perfect fit for your store’s unique design.