oont-contents/themes/old-oont-themev2/inc/templates/exchange-request.php
2025-02-08 15:10:23 +01:00

148 lines
No EOL
12 KiB
PHP

<main id="exchange-details" class="softoba_return_wrapper query_details-body query_detail-wrapper query-step__one">
<div class="softoba-loader" style="display:none;"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>
<div class="query_detail-body">
<h3>Exchange</h3>
<div class="qd--terms">
<div id="softoba_message"></div>
<h4>THESE ARE THE STEPS YOU SHOULD FOLLOW:</h4>
<ol type="1">
<li>SELECT PRODUCT FOR EXCHANGE:CHOOSE THE PRODUCT THAT YOU WISH TO EXCHANGE FROM THE LIST PROVIDED. IF THE DESIRED PRODUCT IS STILL AVAILABLE. YOU CAN PROCEED WITH THE EXCHANGE.</li>
<li>SUBMIT EXCHANGE REQUEST:ONCE YOU HAVE SELECTED THE PRODUCT FOR EXCHANGE CLICK THE:"REQUEST EXCHANGE" BUTTON TO PROCEED.</li>
<li>PAY SHIPPING FEES/ SUBMIT : TO PROCEED WITH THE EXCHANGE, A SHIPPING FEE MAY APPLY.</li>
<li>**OUR TEAM WILL PROCESS YOUR REQUEST WITHIN 1-3 BUSINESS DAYS. DURING THIS TIME, WE WILL PREPARE THE EXCHANGE AND MAKE NECESSARY ARRANGEMENTS FOR SHIPPING.</li>
</ol>
</div>
<form method="POST" id="final_exchange_form">
<div class="qd--order-detail">
<h4 class="order-id">#<?php echo esc_html( $order_number ); ?></h4>
<ul class="qd_customer-info">
<li><strong><?php _e( 'Customer:', 'astra' ); ?></strong> <span><?php echo esc_html( $customer_name ); ?></span></li>
<li><strong><?php _e( 'Tel:', 'astra' ); ?></strong> <span><?php echo esc_html( $customer_tel ); ?></span></li>
<li><strong><?php _e( 'Email:', 'astra' ); ?></strong> <span><?php echo esc_html( $customer_email ); ?></span></li>
<li><strong><?php _e( 'Address:', 'astra' ); ?></strong> <span><?php echo softoba_display_order_data_exchange($order); ?></span></li>
</ul>
</div>
<div class="qd--products-info-body">
<h4>Order Details</h4>
<ul class="order_details-wrapper" id="selected_exchange_product">
<!-- Product Card -->
<?php
if ($order instanceof WC_Order) :
foreach ($order->get_items() as $item) :
$variation_id = $item->get_variation_id();
$itemId = $item->get_id();
// $product = wc_get_product($variation_id ? $variation_id : $product_id);
$product_id = $item->get_product_id();
$product = wc_get_product($product_id);
if ($product) :
$product_name = $item->get_name();
$product_price = $item->get_total();
$product_image = $product->get_image();
$product_quantity = $item->get_quantity();
?>
<li class="order_details-item">
<div class="order_details--row">
<div class="od_col-left od_product-img">
<?php echo $product_image; ?>
</div>
<div class="od_col-middle od_product-detail">
<h5><?php echo esc_html( $product_name );?></h5>
<ul>
<?php
if ($product && $product->is_type('variable')) {
$get_variation = new WC_Product_Variation($variation_id);
$get_variation_attributes = $get_variation->get_variation_attributes();
echo '<li>' . wc_get_formatted_variation( $get_variation_attributes, true ) . '</li>';
}
?>
<input type="hidden" class="ex_ordered_variation" name="order_variation_id[]" value="<?php echo esc_attr( $variation_id ); ?>">
<input type="hidden" class="ex_item_id" name="order_item_id[]" value="<?php echo esc_attr( $itemId ); ?>">
<input type="hidden" class="ex_total_qty" name="total_qty[]" value="<?php echo esc_attr( $product_quantity ); ?>">
<input type="hidden" class="ex_product_price" name="product_price[]" value="<?php echo esc_attr( $product_price ); ?>">
<input type="hidden" class="ex_product_id" name="product_id[]" value="<?php echo esc_attr( $product_id ); ?>">
<li>Quantity: <?php echo esc_html( $product_quantity ); ?> Pcs</li>
<li><?php echo wc_price($product_price); ?></li>
</ul>
</div>
<div class="od_col-right od_product-option">
<div class="exchange-btn-inner">
<label for="exchange_<?php echo esc_attr( $itemId ); ?>">
<input id="exchange_<?php echo esc_attr( $itemId ); ?>" class="exchange_card_check" type="checkbox" name="exchange_checkbox">
<span class="softoba-cover-checkbox">
<svg class="softoba-checkbox--svg" viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<span clas="exchange-label"><?php _e( 'Exchange', 'astra' ); ?></span>
</label>
</div>
<ul class="od_change-size">
<li>
<?php
// Check if the product is a variable product
// if ($product && $product->is_type('variable')) {
// $available_variations = $product->get_available_variations();
// echo '<select class="exchange_variation" name="selected_variation_id[]" data-product-id="'.$product_id.'">';
// foreach ($available_variations as $variation) {
// // Get the variation attributes as a formatted string
// // $attributes_str = implode(', ', $variation['attributes']);
// $attributes_str = wc_get_formatted_variation($variation['attributes'], false, false, false);
// // Determine if this variation was ordered
// $is_ordered_variation = $variation['variation_id'] == $variation_id; // Compare with variation_id
// // Check if the variation is in stock
// $is_in_stock = $variation['is_in_stock'];
// // Output the option for the variation, and mark it as selected if it was ordered
// echo '<option value="' . $variation['variation_id'] . '" ' . selected($is_ordered_variation, true, false) . ' ' . ($is_in_stock ? '' : 'disabled') . '>' . $attributes_str . '</option>';
// // echo '<option value="' . $variation['variation_id'] . '" ' . selected($is_ordered_variation, true, false) . '>' . $attributes_str . '</option>';
// }
// echo '</select>';
// }
if ($product && $product->is_type('variable')) {
$available_variations = $product->get_available_variations();
echo '<select class="exchange_variation" name="selected_variation_id[]" data-product-id="'.$product_id.'">';
foreach ($available_variations as $variation) {
// Get the variation attributes as a formatted string
$attributes_str = wc_get_formatted_variation($variation['attributes'], false, false, false);
// Determine if this variation was ordered
$is_ordered_variation = $variation['variation_id'] == $variation_id; // Compare with variation_id
// Check if the variation is in stock
$is_in_stock = $variation['is_in_stock'];
// Output the option for the variation, and mark it as selected if it was ordered
echo '<option value="' . $variation['variation_id'] . '" ' . ($is_in_stock && !$is_ordered_variation ? '' : 'disabled') . '>' . $attributes_str . '</option>';
}
echo '</select>';
}
?>
</li>
<li>
<label for="exchange_qty_<?php echo esc_attr( $itemId ); ?>">Exchange Quantity</label>
<select id="exchange_qty_<?php echo esc_attr( $itemId ); ?>" class="ex_exchange_qty" name="ex_exchange_qty[]">
<?php
// Loop to generate quantity options
for ($i = 1; $i <= $product_quantity; $i++) {
$label = ($i === 1) ? 'piece' : 'pieces';
echo "<option value='$i'>$i $label</option>";
}
?>
</select>
</li>
</ul>
</div>
</div>
</li>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
<input type="hidden" name="order_id" id="ex_order_id" value="<?php echo esc_attr( $order_number ); ?>">
<input type="hidden" name="exchange_nonce" value="<?php echo wp_create_nonce('exchange_nonce'); ?>" />
<button class="qd_submit-btn" id="submit_exchange_request">Request Exchange</button>
</form>
</div>
</main>