order delivery process
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class Wiaas_Admin_Order_Process_Flow {
|
||||
|
||||
public static function init() {
|
||||
add_action('add_meta_boxes', array(__CLASS__, 'create_custom_meta_box'), 100);
|
||||
}
|
||||
|
||||
public static function create_custom_meta_box() {
|
||||
add_meta_box(
|
||||
'order_process_flow_meta_box',
|
||||
__('Order Process Flow', 'cmb'),
|
||||
'Wiaas_Admin_Order_Process_Flow::add_process_flow_meta_box',
|
||||
'shop_order',
|
||||
'normal',
|
||||
'default'
|
||||
);
|
||||
|
||||
add_meta_box(
|
||||
'order_delivery_dates_meta_box',
|
||||
__('Delivery dates', 'cmb'),
|
||||
'Wiaas_Admin_Order_Process_Flow::add_delivery_dates_meta_box',
|
||||
'shop_order',
|
||||
'normal',
|
||||
'default'
|
||||
);
|
||||
}
|
||||
|
||||
public static function add_process_flow_meta_box(){
|
||||
global $post;
|
||||
|
||||
$order_id = $post->ID;
|
||||
|
||||
$process = Wiaas_Delivery_Process::get_order_delivery_process($order_id);
|
||||
|
||||
if ($process === NULL){
|
||||
$list_of_delivery_processes = Wiaas_Delivery_Process::get_available_delivery_processes();
|
||||
require 'views/html-order-select-delivery-process.php';
|
||||
}else{
|
||||
$title = $process['name'];
|
||||
$steps = $process['steps'];
|
||||
|
||||
require 'views/html-order-process-flow.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function add_delivery_dates_meta_box(){
|
||||
// global $post;
|
||||
|
||||
// $order_id = $post->ID;
|
||||
|
||||
// $suppliers = Wiaas_Order::get_suppliers($order_id);
|
||||
|
||||
// require 'views/html-order-delivery-dates.php';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Wiaas_Admin_Order_Process_Flow::init();
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<style>
|
||||
.collapsible {
|
||||
background-color: #777;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 18px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
text-align: left;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.collapsible-active, .collapsible:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.collapsible-content {
|
||||
padding: 0 18px;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.2s ease-out;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h3><?php echo $title ?></h3>
|
||||
<br/>
|
||||
<?php
|
||||
foreach($steps as $index => $step){
|
||||
$count = $index + 1;
|
||||
echo '<button class="collapsible">' . $count . '. ' . $step['short_desc'] . '</button>';
|
||||
echo '<div class="collapsible-content">';
|
||||
echo $step['full_desc'];
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var coll = document.getElementsByClassName("collapsible");
|
||||
var i;
|
||||
|
||||
for (i = 0; i < coll.length; i++) {
|
||||
coll[i].addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
this.classList.toggle("collapsible-active");
|
||||
var content = this.nextElementSibling;
|
||||
if (content.style.maxHeight){
|
||||
content.style.maxHeight = null;
|
||||
} else {
|
||||
content.style.maxHeight = content.scrollHeight + "px";
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
.delivery-process {
|
||||
background-color: #777;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 18px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
text-align: left;
|
||||
outline: none;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.delivery-process:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>Please select a process for the order:</h1>
|
||||
<br/>
|
||||
<?php
|
||||
foreach($list_of_delivery_processes as $index => $process){
|
||||
echo '<button class="delivery-process" id=' . $process['id'] . '>' . $process['title'] . '</button>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" >
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('.delivery-process').click(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
var data = {
|
||||
action: 'wiaas_create_order_delivery_process',
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( "wiaas_create_order_delivery_process" ) ?>',
|
||||
order: '<?php echo $order_id ?>',
|
||||
form: e.target.id
|
||||
|
||||
};
|
||||
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$.post(ajaxurl, data, function(response) {
|
||||
if (response.success){
|
||||
location.reload();
|
||||
}else{
|
||||
alert(response.data[0].message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user