The order number belongs to the user or not - wordpress

I wanted to make a series of changes on the page checkout/thankyou.php woocommerce
if ( is_user_logged_in() ) {
if ( order number Belongs to user ???? ) {
show order details
} else { echo 'not show order details'; }
}
But I do not know how to check whether the order number belongs to the user or not
If the custom number entered belongs to him, show the order details
If the order number does not belong to the user, do not display the order details
I searched the site for about 3 hours but did not find anything, then I decided to ask a question

You can check with user id from order object $order->user_id; and check against the current logged-in user id for that you can use get_current_user_id(). try the below code.
thankyou.php
<?php
/**
* Thankyou page
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/thankyou.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files, and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 3.7.0
*/
defined( 'ABSPATH' ) || exit;
$user_id = $order->user_id;
if( is_user_logged_in() && $user_id == get_current_user_id() ){ ?>
<div class="woocommerce-order">
<?php
if ( $order ) :
do_action( 'woocommerce_before_thankyou', $order->get_id() );
?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php esc_html_e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?></p>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions">
<?php esc_html_e( 'Pay', 'woocommerce' ); ?>
<?php if ( is_user_logged_in() ) : ?>
<?php esc_html_e( 'My account', 'woocommerce' ); ?>
<?php endif; ?>
</p>
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
<li class="woocommerce-order-overview__order order">
<?php esc_html_e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<li class="woocommerce-order-overview__date date">
<?php esc_html_e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<?php if ( is_user_logged_in() && $order->get_user_id() === get_current_user_id() && $order->get_billing_email() ) : ?>
<li class="woocommerce-order-overview__email email">
<?php esc_html_e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $order->get_billing_email(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<?php endif; ?>
<li class="woocommerce-order-overview__total total">
<?php esc_html_e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<?php if ( $order->get_payment_method_title() ) : ?>
<li class="woocommerce-order-overview__payment-method method">
<?php esc_html_e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), null ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php endif; ?>
</div>
<?php }else{
echo 'Your custom message here.';
} ?>

Related

How to add woocommerce order table to dokan vendor menu?

I want to integrate Woocommerce my-account dashboard into Dokan vendor dashboard navigation.
for this work I add below code to functions.php in child theme.
//add menu to Dokan vendor dashboard
add_filter( 'dokan_query_var_filter', 'dokan_load_document_menu' );
function dokan_load_document_menu( $query_vars ) {
$query_vars['myOrder'] = 'myOrder';
return $query_vars;
}
add_filter( 'dokan_get_dashboard_nav', 'dokan_add_help_menu' );
function dokan_add_help_menu( $urls ) {
$urls['myOrder'] = array(
'title' => __( 'Help', 'dokan'),
'icon' => '<i class="fa fa-user"></i>',
'url' => dokan_get_navigation_url( 'myOrder' ),
'pos' => 51
);
return $urls;
}
add_action( 'dokan_load_custom_template', 'dokan_load_template' );
function dokan_load_template( $query_vars ) {
if ( isset( $query_vars['myOrder'] ) ) {
require_once dirname( __FILE__ ). '/test.php';
}
}
I add orders.php file in child theme and in include this file to test.php file.
test.php code is :
<?php
/**
* Dokan Dashboard Template
*
* Dokan Main Dahsboard template for Fron-end
*
* #since 2.4
*
* #package dokan
*/
?>
<div class="dokan-dashboard-wrap">
<?php
/**
* dokan_dashboard_content_before hook
*
* #hooked get_dashboard_side_navigation
*
* #since 2.4
*/
do_action( 'dokan_dashboard_content_before' );
?>
<div class="dokan-dashboard-content">
<?php
/**
* dokan_dashboard_content_before hook
*
* #hooked show_seller_dashboard_notice
*
* #since 2.4
*/
do_action( 'dokan_help_content_inside_before' );
?>
<article class="help-content-area">
<h1>Add Your Content</h1>
<?php //echo do_shortcode("[woocommerce_orders]")
?>
<?php require_once "orders.php" ?>
</article><!-- .dashboard-content-area -->
<?php
/**
* dokan_dashboard_content_inside_after hook
*
* #since 2.4
*/
do_action( 'dokan_dashboard_content_inside_after' );
?>
</div><!-- .dokan-dashboard-content -->
<?php
/**
* dokan_dashboard_content_after hook
*
* #since 2.4
*/
do_action( 'dokan_dashboard_content_after' );
?>
</div><!-- .dokan-dashboard-wrap -->
and orders.php code is :
<?php
/**
* Orders
*
* Shows orders on the account page.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/orders.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 3.7.0
*/
defined( 'ABSPATH' ) || exit;
do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<?php if ( $has_orders ) : ?>
<table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table">
<thead>
<tr>
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
<th class="woocommerce-orders-table__header woocommerce-orders-table__header-<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php
foreach ( $customer_orders->orders as $customer_order ) {
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$item_count = $order->get_item_count() - $order->get_item_count_refunded();
?>
<tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order">
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
<td class="woocommerce-orders-table__cell woocommerce-orders-table__cell-<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
<?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
<?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>
<?php elseif ( 'order-number' === $column_id ) : ?>
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
<?php echo esc_html( _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number() ); ?>
</a>
<?php elseif ( 'order-date' === $column_id ) : ?>
<time datetime="<?php echo esc_attr( $order->get_date_created()->date( 'c' ) ); ?>"><?php echo esc_html( wc_format_datetime( $order->get_date_created() ) ); ?></time>
<?php elseif ( 'order-status' === $column_id ) : ?>
<?php echo esc_html( wc_get_order_status_name( $order->get_status() ) ); ?>
<?php elseif ( 'order-total' === $column_id ) : ?>
<?php
/* translators: 1: formatted order total 2: total order items */
echo wp_kses_post( sprintf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ) );
?>
<?php elseif ( 'order-actions' === $column_id ) : ?>
<?php
$actions = wc_get_account_orders_actions( $order );
if ( ! empty( $actions ) ) {
foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
echo '' . esc_html( $action['name'] ) . '';
}
}
?>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php do_action( 'woocommerce_before_account_orders_pagination' ); ?>
<?php if ( 1 < $customer_orders->max_num_pages ) : ?>
<div class="woocommerce-pagination woocommerce-pagination--without-numbers woocommerce-Pagination">
<?php if ( 1 !== $current_page ) : ?>
<a class="woocommerce-button woocommerce-button--previous woocommerce-Button woocommerce-Button--previous button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php esc_html_e( 'Previous', 'woocommerce' ); ?></a>
<?php endif; ?>
<?php if ( intval( $customer_orders->max_num_pages ) !== $current_page ) : ?>
<a class="woocommerce-button woocommerce-button--next woocommerce-Button woocommerce-Button--next button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php esc_html_e( 'Next', 'woocommerce' ); ?></a>
<?php endif; ?>
</div>
<?php endif; ?>
<?php else : ?>
<div class="woocommerce-message woocommerce-message--info woocommerce-Message woocommerce-Message--info woocommerce-info">
<a class="woocommerce-Button button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"><?php esc_html_e( 'Browse products', 'woocommerce' ); ?></a>
<?php esc_html_e( 'No order has been made yet.', 'woocommerce' ); ?>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?>
but don't when I watch page just work else in orders.php file.
(I don't change navigation title and the title is 'HELP')
enter image description here
how I can fix this problem?

Display shipping for each products on invoice - Woocommerce

I want to show a shipping row on invoice because I use the plugin "Multiple Packages for WooCommerce". Indeed for each product the customer can choose "livraison express (25€)" or "Livraison Franco de port" (0€).
Currently my invoice looks like this
So I wish it looked like this :
The shipping method above each products and only the amount of delivery in the row of total.
In the file "invoice.php", I Have this :
<tbody>
<?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
<tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
<td class="product">
<?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
<span class="item-name"><?php echo $item['name']; ?></span>
<?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
<span class="item-meta"><?php echo $item['meta']; ?></span>
<dl class="meta">
<?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
<?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'Référence :', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?></dl>
<?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
</td>
<td class="quantity"><?php echo $item['quantity']; ?></td>
<td class="price"><?php echo $item['order_price']; ?></td>
</tr>
<?php endforeach; endif; ?>
</tbody>
So I try to add this code
<?php echo $order->get_shipping_to_display(); ?>
Like this
<dl class="meta">
<?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
<?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'Référence :', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?>
<?php /*if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></dd><?php endif;*/ ?>
<dt class="sku"><?php_e( 'Livraison :', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku">
<?php echo $order->get_shipping_to_display(); ?></dd></dl>
but i get this :
So I understand that this code call the shipping for the order and not for the item but if I try <?php echo $item->get_shipping_to_display(); ?> I have an error.
Is someone can help me?

Add editable address fields to WooCommerce invoice page

Please forgive such a basic question. I'm relatively new to WooCommerce theme development and genuinely trying to understand how wordpress handles customer data so I can learn how to manipulate it. If this question is still too broad, (My previous question was closed for that reason) I'd even welcome a few links which help point me in the correct direction and explain the area I'm looking at.
What I am trying to do is add editable address fields to the page customers see when we email them an invoice. (form-pay.php)
Initially, I tried adding fields manually using variation on the following code for each field in functions.php and calling it in from order-pay.php:
<p class="form-row form-row-first">
<label for="billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?><span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
However, when I do it this way, it adds the address details associated with my own WordPress login, rather than the customer's address associated with the invoice.
I have worked through the woocommerce codex on hooks and filters and also found the answer to this question which allowed the correct address fields to be added.
This is where my question seems to differ from a lot of the solutions I've found, in that most solutions are for updating the billing and shipping address of the current cart or logged in user, rather than that associated with a specific invoice.
Here's the fields I've added to form-pay.php.
<h2 class="woocommerce-column__title"><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
<address>
<?php echo wp_kses_post( $order->get_formatted_billing_address( __( 'N/A', 'woocommerce' ) ) ); ?>
<?php if ( $order->get_billing_phone() ) : ?>
<p class="woocommerce-customer-details--phone"><?php echo esc_html( $order->get_billing_phone() ); ?></p>
<?php endif; ?>
<?php if ( $order->get_billing_email() ) : ?>
<p class="woocommerce-customer-details--email"><?php echo esc_html( $order->get_billing_email() ); ?></p>
<?php endif; ?>
</address>
<h2 class="woocommerce-column__title"><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>
<address>
<?php echo wp_kses_post( $order->get_formatted_shipping_address( __( 'N/A', 'woocommerce' ) ) ); ?>
</address>
<!-- Form -->
<h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>
<?php do_action( 'woocommerce_before_checkout_billing_form', $order ); ?>
<div class="woocommerce-billing-fields__field-wrapper">
<?php
$fields = WC()->checkout->get_checkout_fields( 'billing' );
foreach ( $fields as $key => $field ) {
$field_name = $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
}
woocommerce_form_field( $key, $field, $field['value'] );
}
?>
</div>
<?php do_action( 'woocommerce_after_checkout_billing_form', $order ); ?>
<h3><?php _e( 'Shipping details', 'woocommerce' ); ?></h3>
<?php do_action( 'woocommerce_before_checkout_shipping_form', $order ); ?>
<div class="woocommerce-shipping-fields__field-wrapper">
<?php
$fields = WC()->checkout->get_checkout_fields( 'shipping' );
foreach ( $fields as $key => $field ) {
$field_name = $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
}
woocommerce_form_field( $key, $field, $field['value'] );
}
?>
</div>
<?php do_action( 'woocommerce_after_checkout_shipping_form', $order ); ?>
The fields correctly appear on the invoice page now which display all address details I have already added to the invoice. I just need to understand what logic I need to attach to a button to tell WooCommerce to update the record.
As I said, I recognise this is a fundamentally basic question, but so far I've failed to find an explanation that works specifically in the context of updating the invoice rather than the cart.

woocommerce update date in myAccount after status change

Hello i have a Question.
If i change the status of an order from the Admin, the customer needs to get a last status changed date on the myaccount page in my orders.
Do you have any Idea how to implement this?
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<p><?php
/* translators: 1: order number 2: order changed date 3: order status */
printf(
__( 'Ihre Bestellung #%1$s vom %4$s ist %3$s.<br> Letzte Statusänderung am %2$s.<br><br>', 'woocommerce' ),
'<mark class="order-number">' . $order->get_order_number() . '</mark>',
'<mark class="order-date">' . wc_format_datetime( $order->get_date_modified() ) . '</mark>',
'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>',
'<mark class="order-date">' . wc_format_datetime( $order->get_date_created() ) . '</mark>'
);
?></p>
<?php if ( $notes = $order->get_customer_order_notes() ) : ?>
<h2><?php _e( '<br>Order updates', 'woocommerce' ); ?></h2>
<ol class="woocommerce-OrderUpdates commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="woocommerce-OrderUpdate comment note">
<div class="woocommerce-OrderUpdate-inner comment_container">
<div class="woocommerce-OrderUpdate-text comment-text">
<p class="woocommerce-OrderUpdate-meta meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
<div class="woocommerce-OrderUpdate-description description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php do_action( 'woocommerce_view_order', $order_id ); ?>
I added a new mark class with get_date_modified.
Then it shows me the last Date i modified the status.
I only want to see the Text "Letzte Statusänderung am %2$s" with the Date, if selected status is "wc-completed".
So i need code, that only shows text and date of modified status if the status of the order is wc-completed.
I dont know how to realize it another way.
I attached a Screenshot to visualize what i want to create.Screenshot

Woocommerce add to cart message not showing

After implementing and doing design changes locally on a project, the woocommerce messages are not showing anymore on the single product page. I don't get any console errors, so I don't think it has anything to do with that. And the request is processed since when I go to see the cart from another page, then the item that I was trying to add is on the list, it is just that the message doesn't show on a singe product page. I am not sure where to go about?
This is the add-to-cart/variable file:
<?php
/**
* Variable product add to cart
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $product;
$attribute_keys = array_keys( $attributes );
do_action( 'woocommerce_before_add_to_cart_form' ); ?>
<form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->id ); ?>" data-product_variations="<?php echo esc_attr( json_encode( $available_variations ) ) ?>">
<?php do_action( 'woocommerce_before_variations_form' ); ?>
<?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
<p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?></p>
<?php else : ?>
<div class="variations" cellspacing="0">
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
<div class="row">
<div class="small-3 columns">
<label for="<?php echo sanitize_title( $attribute_name ); ?>" class="text-left middle">
<strong><?php echo wc_attribute_label( $attribute_name ); ?></strong>
</label>
</div>
<div class="small-9 columns">
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
?>
</div>
</div>
<?php endforeach;?>
</div>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<div class="row single_variation_wrap" style="display:none;">
<div class="small-9 small-offset-3 columns">
<?php
/**
* woocommerce_before_single_variation Hook
*/
do_action( 'woocommerce_before_single_variation' );
/**
* woocommerce_single_variation hook. Used to output the cart button and placeholder for variation data.
* #since 2.4.0
* #hooked woocommerce_single_variation - 10 Empty div for variation data.
* #hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button.
*/
do_action( 'woocommerce_single_variation' );
/**
* woocommerce_after_single_variation Hook
*/
do_action( 'woocommerce_after_single_variation' );
?>
</div>
</div>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
<?php endif; ?>
<?php do_action( 'woocommerce_after_variations_form' ); ?>
</form>
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
This looks like quite an old version of the variable.php template, if you have anything higher than WooCommerce 2.4.0 installed (i checked against the 2.5.0 version of this template) there are enough significant changes that might break certain parts of WooCommerce.
One difference that immediately stood out to me was that the data-product_variations attribute on the form in later versions uses htmlspecialchars instead of esc_attr.
Hope this helps!

Resources