-
Notifications
You must be signed in to change notification settings - Fork 0
/
vend_order_config.php
704 lines (674 loc) · 50.7 KB
/
vend_order_config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
<?php
$LAIDKey = get_option('linksync_laid');
$testMode = get_option('linksync_test');
$apicall = new linksync_class($LAIDKey, $testMode);
$gatway = new WC_Payment_Gateways;
# Get Payment Types
for ($count_payment = 1; $count_payment <= 3; $count_payment++) {
$payment = $apicall->linksync_getpaymentTypes();
if (isset($payment) && !empty($payment)) {
break;
}
}
# Get Taxes
for ($count_taxes = 1; $count_taxes <= 3; $count_taxes++) {
$taxes = $apicall->linksync_getTaxes();
if (isset($taxes) && !empty($taxes)) {
break;
}
}
#Get Order Status
for ($count_order_Status = 1; $count_order_Status <= 3; $count_order_Status++) {
$order_Status = $apicall->linksync_get_order_statuses();
if (isset($order_Status) && !empty($order_Status)) {
break;
}
}
if (isset($_POST['save_order_sync_setting'])) {
//Woocommers To VEND
if (isset($_POST['order_sync_type']) && !empty($_POST['order_sync_type'])) {
update_option('order_sync_type', $_POST['order_sync_type']);
}
if (isset($_POST['order_status_wc_to_vend'])) {
update_option('order_status_wc_to_vend', isset($_POST['order_status_wc_to_vend']) ? $_POST['order_status_wc_to_vend'] : 'off' );
} else {
update_option('order_status_wc_to_vend', 'off');
}
if (isset($_POST['wc_to_vend_outlet'])) {
$register = 'wc_to_vend_register|' . $_POST['wc_to_vend_outlet'];
if (isset($_POST[$register])) {
update_option('wc_to_vend_register', isset($_POST[$register]) ? $_POST[$register] : 'off');
} else {
update_option('wc_to_vend_register', 'off');
}
$user = 'wc_to_vend_user|' . $_POST['wc_to_vend_outlet'];
if (isset($user)) {
update_option('wc_to_vend_user', isset($_POST[$user]) ? $_POST[$user] : 'off');
} else {
update_option('wc_to_vend_user', 'off');
}
update_option('wc_to_vend_outlet', isset($_POST['wc_to_vend_outlet']) ? $_POST['wc_to_vend_outlet'] : 'off');
} else {
update_option('wc_to_vend_outlet', 'off');
}
if (isset($_POST['wc_to_vend_tax']) && !empty($_POST['wc_to_vend_tax'])) {
$all_taxes = implode(',', $_POST['wc_to_vend_tax']);
update_option('wc_to_vend_tax', $all_taxes);
} else {
update_option('wc_to_vend_tax', 'off');
}
if (isset($_POST['wc_to_vend_payment']) && !empty($_POST['wc_to_vend_payment'])) {
$all_payment = implode(',', $_POST['wc_to_vend_payment']);
update_option('wc_to_vend_payment', $all_payment);
} else {
update_option('wc_to_vend_payment', 'off');
}
if ($_POST['wc_to_vend_export']) {
update_option('wc_to_vend_export', isset($_POST['wc_to_vend_export']) ? $_POST['wc_to_vend_export'] : 'off');
} else {
update_option('wc_to_vend_export', 'off');
}
//From VEND To Woocommers
if (isset($_POST['order_vend_to_wc'])) {
update_option('order_vend_to_wc', isset($_POST['order_vend_to_wc']) ? $_POST['order_vend_to_wc'] : 'off');
} else {
update_option('order_vend_to_wc', 'off');
}
if (isset($_POST['vend_to_wc_tax']) && !empty($_POST['vend_to_wc_tax'])) {
$all_taxes = implode(',', $_POST['vend_to_wc_tax']);
update_option('vend_to_wc_tax', $all_taxes);
} else {
update_option('vend_to_wc_tax', 'off');
}
if (isset($_POST['vend_to_wc_payments']) && !empty($_POST['vend_to_wc_payments'])) {
$payment_vend = implode(',', $_POST['vend_to_wc_payments']);
update_option('vend_to_wc_payments', $payment_vend);
} else {
update_option('vend_to_wc_payments', 'off');
}
if (isset($_POST['vend_to_wc_customer'])) {
update_option('vend_to_wc_customer', isset($_POST['vend_to_wc_customer']) ? $_POST['vend_to_wc_customer'] : 'off');
} else {
update_option('vend_to_wc_customer', 'off');
}
if (isset($_POST['order_sync_type']) && $_POST['order_sync_type'] == 'vend_to_wc-way') {
// Update "since"
$current_date_time_string = strtotime(date("Y-m-d H:i:s"));
$time_offset = get_option('linksync_time_offset');
if (isset($time_offset) && !empty($time_offset)) {
$time = $current_date_time_string + $time_offset;
} else {
$time = $current_date_time_string; # UTC
}
$result_time = date("Y-m-d H:i:s", $time);
#order update Request time
update_option('order_time_suc', $result_time);
// Set Import To Yes on the base of point 31
$result = $apicall->testConnection();
$plugin_file = dirname(__FILE__) . '/linksync.php';
$plugin_data = get_plugin_data($plugin_file, $markup = true, $translate = true);
$linksync_version = $plugin_data['Version'];
$webhook = $apicall->webhookConnection(plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code'), $linksync_version, 'yes', 'no');
if (isset($webhook) && !empty($webhook)) {
if (isset($webhook['result']) && $webhook['result'] == 'success') {
$apicall->add('WebHookConnection', 'success', 'Connected to a file ' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code'), $LAIDKey);
update_option('linksync_addedfile', '<a href="' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code') . '">' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code') . '</a>');
}
} else {
$apicall->add('WebHookConnection', 'fail', 'Order-Config File: Connected to a file ' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code'), $LAIDKey);
}
} else {
$result = $apicall->testConnection();
$plugin_file = dirname(__FILE__) . '/linksync.php';
$plugin_data = get_plugin_data($plugin_file, $markup = true, $translate = true);
$linksync_version = $plugin_data['Version'];
$webhook = $apicall->webhookConnection(plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code'), $linksync_version, 'no', 'no');
if (isset($webhook) && !empty($webhook)) {
if (isset($webhook['result']) && $webhook['result'] == 'success') {
$apicall->add('WebHookConnection', 'success', 'Connected to a file ' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code'), $LAIDKey);
update_option('linksync_addedfile', '<a href="' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code') . '">' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code') . '</a>');
}
} else {
$apicall->add('WebHookConnection', 'fail', 'Order-Config File: Connected to a file ' . plugins_url() . '/linksync/update.php?c=' . get_option('webhook_url_code'), $LAIDKey);
}
}
if ($_POST['order_sync_type'] != 'disabled') {
if ($_POST['order_sync_type'] == 'vend_to_wc-way') {
$enable = 'Vend to Woo';
} else {
$enable = 'Woo to Vend';
}
$setting_message = $enable . ' is enable';
} else {
$setting_message = 'Sync Setting Disabled';
}
linksync_class::add('Order Sync Setting', 'success', $setting_message, $LAIDKey);
}
?>
<h3>Order Syncing Configuration</h3>
<form name="save_order_sync_setting" method="post">
<fieldset>
<legend>Order Syncing Type</legend>
<div>
<input type="radio" name="order_sync_type" id="wc_to_vend_sync_id" <?php echo (get_option('order_sync_type') == 'wc_to_vend' ? 'checked' : ''); ?> value="wc_to_vend"> WooCommerce to Vend <a href="https://www.linksync.com/help/woocommerce"><img title="If you're using the Vend to WooCommerce product syncing option, then you need to enable this option so that any sales in WooCommerce are synced to Vend - this ensures that the inventory levels in Vend are updated based on any orders entered in WooCommerce. " style="margin-bottom: -4px; " src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a>
<input type="radio" name="order_sync_type" id="vend_to_wc_sync_id" <?php echo (get_option('order_sync_type') == 'vend_to_wc-way' ? 'checked' : ''); ?> value="vend_to_wc-way"> Vend to WooCommerce <a href="https://www.linksync.com/help/woocommerce"><img title="If you're using the WooCommerce to Vend product syncing option, then you need to enable this option so that any sales in Vend are synced to WooCommerce - this ensures that the inventory levels in WooCommerce are updated based on any orders entered in Vend." style="margin-bottom: -4px; " src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a>
<input type="radio" name="order_sync_type" id="disabled_sync_id" <?php echo (get_option('order_sync_type') == 'disabled' ? 'checked' : ''); ?> value="disabled"> Disabled <a href="https://www.linksync.com/help/woocommerce"><img title="Prevent any orders syncing between Vend and WooCommerce stores." style="margin-bottom: -4px; " src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a>
</div>
</fieldset>
<div id="order_sync_setting" style="display:<?php
if (get_option('order_sync_type') == 'disabled') {
echo "none";
} else {
echo "block";
}
?>">
<div id="order_sync_wc_to_vend" style="display:<?php
if (get_option('order_sync_type') == 'wc_to_vend' || get_option('order_sync_type') == 'enable') {
echo "block";
} else {
echo "none";
}
?>">
<h3>WooCommerce to Vend:</h3>
<!------------------------------------------------------------------ Order Status Wc_to_Vend------------------------------------>
<table class="form-table">
<tbody>
<tr valign="top">
<th class="titledesc">Order Status<a href="https://www.linksync.com/help/woocommerce"><img title="Use this option to select what status the order must be before it is exported. Keep in mind that an order can only be exported to Vend once, and once exported, it can not be edited in Vend. " style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th>
<td class="forminp forminp-checkbox">
<?php
if (isset($order_Status) && !empty($order_Status)) {
foreach ($order_Status as $order_name => $order_value) {
?><input type="radio" <?php
echo (get_option('order_status_wc_to_vend') == $order_name ? 'checked' : '');
?> value="<?php echo $order_name ?>" name="order_status_wc_to_vend" /><?php echo $order_value ?> <br>
<?php
}
?>
<br><?php
} else {
?><span style='color:red; '><?php echo 'Error in getting Order-Status: No Getting Expecting Data!!<br>' ?></span><?php
}
?></td>
</tr>
<!------------------------------------------------------------------ Outlet Wc_to_Vend------------------------------------>
<tr valign="top">
<?php
# Get Outlets
for ($count_outlets = 1; $count_outlets <= 3; $count_outlets++) {
$linksync_outlets = $apicall->linksync_getOutlets();
if (isset($linksync_outlets) && !empty($linksync_outlets)) {
break;
}
}
# Get Registers
for ($count_registers = 1; $count_registers <= 3; $count_registers++) {
$registers = $apicall->linksync_getRegisters();
if (isset($registers) && !empty($registers)) {
break;
}
}
# Get Users
for ($count_users = 1; $count_users <= 3; $count_users++) {
$users = $apicall->linksync_getUsers();
if (isset($users) && !empty($users)) {
break;
}
}
$registerDb = get_option('wc_to_vend_register');
$outletDb = get_option('wc_to_vend_outlet');
$userDb = get_option('wc_to_vend_user');
// echo $registerDb;echo "<br>";echo $outletDb;echo "<br>";echo $userDb;
#Check for the Outlets
if (isset($linksync_outlets) && !empty($linksync_outlets)) {
if (!isset($linksync_outlets['errorCode'])) {
if (isset($linksync_outlets['outlets'])) {
if (!empty($outletDb)) {
?>
<th class="titledesc">Outlets<a href="https://www.linksync.com/help/woocommerce"><img title="If you have multiple Outlets in Vend, use this option to select which Outlet you want orders from WooCommerce to be associated with. If you have multiple registers and users for an outlet, you can also choose which register and/or user you want the orders to be imported against. " style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th> <td class="forminp forminp-checkbox"><?php
foreach ($linksync_outlets['outlets'] as $outlet) {
?>
<input type="radio" class="outlet_class" <?php
echo($outletDb == $outlet['id'] ? 'checked' : '');
?> value="<?php echo $outlet['id'] ?>" name="wc_to_vend_outlet" /><?php echo $outlet['name'] ?>
<span class="check" id="<?php echo $outlet['id']; ?>"> <?php
if (!empty($registerDb)) {
?>
<?php if (count($registers['registers']) > 1) {
?><br><b style="margin-left:40px;float: left;">Register :-</b><?php
$display_register = 'display:block;';
} else {
$display_register = 'display:none;';
}
$checkRegister = 0;
foreach ($registers['registers'] as $register) {
if ($outlet['id'] == $register['outlet_id']) {
if ($outlet['id'] != $outletDb) {
if ($checkRegister == 0) {
$checked = "checked";
$checkRegister++;
} else {
$checked = '';
}
} else {
$checked = '';
}
?> <div style="margin-left:20px;float: left;<?php echo $display_register; ?>"><input style="margin-top: 2px;float: left;" type="radio" <?php
if (isset($checked))
echo $checked . ' ';
echo ( $registerDb == $register['id'] ? 'checked' : '');
?> value="<?php echo $register['id'] ?>" name="wc_to_vend_register|<?php echo $outlet['id'] ?>" /><?php echo $register['name'] ?> </div>
<?php
}
}
}
if (!empty($userDb)) {
if (count($users['users']) > 1) {
?><br><b style="margin-left:40px;float: left; ">User :-</b><?php
$display_user = 'display:block;';
} else {
$display_user = 'display:none;';
}
$checkUser = 0;
foreach ($users['users'] as $user) {
if ($outlet['id'] == @$user['outlet_id'] OR @$user['outlet_id'] == null) {
if ($outlet['id'] != $outletDb) {
if ($checkUser == 0) {
$checked = "checked";
$checkUser++;
} else {
$checked = '';
}
} else {
$checked = '';
}
?>
<div style="margin-left:20px;float: left;<?php echo $display_user; ?>"><input type="radio" style="margin-top: 2px;float: left;" <?php
if (isset($checked))
echo $checked . ' ';
echo ( $userDb == $user['id'] . '|' . $user['username'] ? 'checked' : '');
?> value="<?php echo $user['id'] . '|' . $user['username']; ?>" name="wc_to_vend_user|<?php echo $outlet['id'] ?>" /><?php echo $user['name'] . "(<i>" . $user['username'] . "</i>)"; ?></div>
<?php
}
}
}
?></span><br> <?php
}
?></td><?php
} else {
?>
<th class="titledesc">Outlets<a href="https://www.linksync.com/help/woocommerce"><img title="If you have multiple Outlets in Vend, use this option to select which Outlet you want orders from WooCommerce to be associated with. If you have multiple registers and users for an outlet, you can also choose which register and/or user you want the orders to be imported against. " style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th>
<td class="forminp forminp-checkbox"><?php
$checkOutlet = 0;
foreach ($linksync_outlets['outlets'] as $outlet) {
if ($checkOutlet == 0) {
$checked = "checked";
} else {
$checked = '';
}
?>
<br> <input type="radio" class="outlet_class" <?php echo $checked; ?> value="<?php echo $outlet['id'] ?>" name="wc_to_vend_outlet" /><?php echo $outlet['name'] ?>
<span class="check" id="<?php echo $outlet['id']; ?>">
<?php
#Check for the Register
if (isset($registers) && !empty($registers)) {
if (!isset($registers['errorCode'])) {
if (isset($registers['registers'])) {
if (count($registers['registers']) > 1) {
?><br><b style="margin-left:40px;float: left;">Register :-</b><?php
$display_register = 'display:block;';
} else {
$display_register = 'display:none;';
}
$checkRegister = 0;
foreach ($registers['registers'] as $register) {
if ($outlet['id'] == $register['outlet_id']) {
if ($checkRegister == 0) {
$checked = "checked";
$checkRegister++;
} else {
$checked = '';
}
?><div style="margin-left:20px;float: left;<?php echo $display_register; ?>"><input style="margin-top: 2px;float: left;" type="radio" <?php echo $checked;
?> value="<?php echo $register['id'] ?>" name="wc_to_vend_register|<?php echo $outlet['id'] ?>" /><?php echo $register['name'] ?>
</div>
<?php
}
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Register: No Getting Expecting Data!!' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Register : ' . $registers['userMessage'] ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Register: No Getting Expecting Data!!' ?></span><?php
}
?>
<?php
#Check For the User
if (isset($users) && !empty($users)) {
if (!isset($users['errorCode'])) {
if (isset($users['users'])) {
#-------------Changes---------------#
if (count($users['users']) > 1) {
?><br><b style="margin-left:40px;float: left; ">User :-</b><?php
$display = 'display:block;';
} else {
$display = 'display:none;';
}
$i = 0;
foreach ($users['users'] as $user) {
if ($outlet['id'] == $user['outlet_id'] OR $user['outlet_id'] == null) {
if ($i == 0) {
$checked = "checked";
$i++;
} else {
$checked = '';
}
?> <div style="margin-left:20px;float: left;<?php echo $display; ?>"><input style="margin-top: 2px;float: left;" type="radio" <?php echo $checked; ?> value="<?php echo $user['id'] . '|' . $user['username']; ?>" name="wc_to_vend_user|<?php echo $outlet['id'] ?>" /><?php echo $user['name'] . "(<i>" . $user['username'] . "</i>)" ?></div>
<?php
}
}
#-------------Changes----------------#
} else {
?><span style='color:red; '><?php echo 'Error in getting Users : No Getting Expecting Data!!' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Users : ' . $registers['userMessage'] ?></span><?php
}
}
?>
<br>
</span>
<?php
$checkOutlet++;
}
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Outlets: No Getting Expecting Data!!<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Outlets : ' . $linksync_outlets['userMessage'] . '<br>' ?></span><?php
}
}
?>
</td>
</tr>
<!------------------------------------------------------------------ Tax Mapping Wc_to_Vend---------------------------------------->
<tr valign="top">
<th class="titledesc">Tax mapping<a href="https://www.linksync.com/help/woocommerce"><img title="When syncing orders, both Vend and WooCommerce have their own tax configurations - use these Tax Mapping settings to 'map' the Vend taxes with those in your WooCommerce store." style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th>
<td class="forminp forminp-checkbox"><?php
#Check for the Taxes
if (isset($taxes) && !empty($taxes)) {
if (!isset($taxes['errorCode'])) {
if (isset($taxes['taxes'])) {
$taxes_all = explode(',', get_option('wc_to_vend_tax'));
?><ul><legend style="display: inline-block;width:200px;float: left;"> <b>WooCommerce Tax Classes</b></legend> <legend style="display: inline-block;width: 80px; float: left">=></legend> <legend style="display: inline-block; "><b>Vend Taxes</b></legend><br><?php
$implode_tax['tax_name']['standard-tax'] = '';
$tax_classes_list = array_map("rtrim", explode("\n", get_option('woocommerce_tax_classes')));
foreach ($tax_classes_list as $value) {
$taxexplode = explode(" ", strtolower($value));
$implode_tax['tax_name'][implode("-", $taxexplode)] = implode("-", $taxexplode);
}
foreach ($implode_tax['tax_name'] as $tax_classes_name => $woo_taxes) {
global $wpdb;
$tax_rates = mysql_query("SELECT * FROM `" . $wpdb->prefix . "woocommerce_tax_rates` WHERE `tax_rate_class` ='" . $woo_taxes . "'");
if (mysql_num_rows($tax_rates) != 0) {
?> <li><b><?php echo ucfirst($tax_classes_name); ?></b> </li> <?php
while ($tax_rate = mysql_fetch_assoc($tax_rates)) {
?>
<li> <legend style="display: inline-block;width: 180px;float: left;margin-left: 20px;"><?php echo $tax_rate['tax_rate_name']; ?> </legend>
<legend style="display: inline-block;width: 80px; float: left">=></legend>
<legend style="display: inline-block;"><select style="margin-top: -5px"name="wc_to_vend_tax[]">
<?php
foreach ($taxes['taxes'] as $select_tax) {
if (in_array($select_tax['id'] . "/" . $select_tax['name'] . "/" . $select_tax['rate'] . '|' . $tax_rate['tax_rate_name'].'-'.$tax_classes_name, $taxes_all)) {
$selected = "selected";
} else {
$selected = "";
}
echo '<option value="' . $select_tax['id'] . "/" . $select_tax['name'] . "/" . $select_tax['rate'] . '|' . $tax_rate['tax_rate_name'].'-'.$tax_classes_name . '" ' . $selected . '>' . $select_tax['name'] . '</option>';
}
?>
</select></legend> </li>
<?php
}
}
}
?></ul><?php } else {
?><span style='color:red; '><?php echo 'Error in getting Taxes : No Getting Expecting Data!!<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Taxes : ' . $taxes['userMessage'] . '<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Taxes : No Getting Expecting Data!!<br>' ?></span><?php
}
?>
</td>
</tr>
<!------------------------------------------------------------------ Payment Mapping Wc_to_Vend---------------------------------------->
<tr valign="top">
<th class="titledesc">Payment mapping<a href="https://www.linksync.com/help/woocommerce"><img title="When syncing orders, both Vend and WooCommerce have their own payment methods - use these Payment Mapping settings to 'map' the Vend payment methods with those in your WooCommerce store." style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a> </th>
<td class="forminp forminp-checkbox">
<?php
#Check for the Payment
if (isset($payment) && !empty($payment)) {
if (!isset($payment['errorCode'])) {
if (isset($payment['paymentTypes'])) {
?>
<?php
$payment_wc_to_vend = get_option('wc_to_vend_payment');
$wc_to_vend_payment = explode(',', $payment_wc_to_vend);
$payment_gatways = $gatway->payment_gateways();
?><ul><legend style="display: inline-block;width: 20em; float: left"> <b>WooCommerce Payment Gateways</b></legend> <legend style="display: inline-block;width: 3em; float: left">=></legend> <legend style="display: inline-block;width: 25em; "><b>Vend Payment</b></legend><br>
<?php
foreach ($payment_gatways as $gatways) {
if ($gatways->enabled == 'yes') {
?> <li> <legend style="display: inline-block;width: 20em; float: left">
<?php echo $gatways->title; ?></legend> <legend style="display: inline-block;width: 3em; float: left">=></legend>
<legend style="display: inline-block;width: 25em; "><select style="margin-top: -5px" name="wc_to_vend_payment[]">
<?php
foreach ($payment['paymentTypes'] as $payment_mapping) {
if (in_array($payment_mapping['name'] . "%%" . $payment_mapping['id'] . '|' . $gatways->title . '|' . $gatways->id, $wc_to_vend_payment)) {
$selected = "selected";
} else {
$selected = "";
}
echo '<option value="' . $payment_mapping['name'] . "%%" . $payment_mapping['id'] . '|' . $gatways->title . '|' . $gatways->id . '" ' . $selected . '>' . $payment_mapping['name'] . '</option>';
}
?>
</select></legend></li>
<?php }
}
?>
</ul>
<?php } else {
?><span style='color:red; '><?php echo 'Error in getting Payment : No Getting Expecting Data!!<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Payment : ' . $payment['userMessage'] . '<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Payment : No Getting Expecting Data!!<br>' ?></span><?php
}
?>
</td>
</tr>
<!------------------------------------------------------------------ Customer Wc_to_Vend---------------------------------------->
<tr valign="top">
<th class="titledesc">Customer Export</th>
<td class="forminp forminp-checkbox">
<legend style="display: inline-block;width: 25em; "><input type="radio" checked value="customer" <?php echo (get_option('wc_to_vend_export') == 'customer' ? 'checked' : ''); ?> name="wc_to_vend_export" />Export Customer data<a href="https://www.linksync.com/help/woocommerce"><img title="Select this option if you'd like customer data, such as name, email address and shipping and billing address, to be included when exporting orders to Vend." style="margin-left: 4px;margin-bottom: -3px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a> </legend><br>
<legend style="display: inline-block;width: 25em; "><input type="radio" value="cash_sale" <?php echo (get_option('wc_to_vend_export') == 'cash_sale' ? 'checked' : ''); ?> name="wc_to_vend_export" />Export as 'Cash Sale' <a href="https://www.linksync.com/help/woocommerce"><img title="Select this option if you're not interested in including the customer information when exporting orders to Vend. " style="margin-left: 4px;margin-bottom: -3px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></legend></td>
</tr>
</tbody>
</table>
</div><br>
<div id="order_sync_vend_to_wc" style="display:<?php
if (get_option('order_sync_type') == 'vend_to_wc-way' || get_option('order_sync_type') == 'enable') {
echo "block";
} else {
echo "none";
}
?>">
<h3>Vend to WooCommerce:</h3>
<!----------------------------------------------------------Order Vend To WC----------------------------------------->
<table class="form-table">
<tbody>
<tr valign="top">
<th class="titledesc">Order Status<a href="https://www.linksync.com/help/woocommerce"><img title="Use this option to select the default status of the order when it's imported. In most cases you will set this to 'Completed' " style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th>
<td class="forminp forminp-checkbox">
<?php if (isset($order_Status) && !empty($order_Status)) { ?>
<?php
foreach ($order_Status as $order_name => $order_value) {
?> <input type="radio" <?php
echo (get_option('order_vend_to_wc') == $order_name ? 'checked' : '');
?> value="<?php echo $order_name ?>" name="order_vend_to_wc" /><?php echo $order_value ?><br>
<?php
}
?><br><?php
} else {
?><span style='color:red; '><?php echo 'Error in getting Outlets: No Getting Expecting Data!!<br>' ?></span><?php
}
?></td>
</tr>
<!------------------------------------------------------------------ Tax Mapping vend_to_wc---------------------------------------->
<tr valign="top">
<th class="titledesc">Tax mapping<a href="https://www.linksync.com/help/woocommerce"><img title="When syncing orders, both Vend and WooCommerce have their own tax configurations - use these Tax Mapping settings to 'map' the Vend taxes with those in your WooCommerce store. " style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th>
<td class="forminp forminp-checkbox">
<?php
#Check for the Taxes
if (isset($taxes) && !empty($taxes)) {
if (!isset($taxes['errorCode'])) {
if (isset($taxes['taxes'])) {
$taxes_all = explode(',', get_option('vend_to_wc_tax'));
?><ul><legend style="display: inline-block;width: 8em; float: left"> <b> Vend Taxes</b></legend> <legend style="display: inline-block;width: 3em; float: left">=></legend> <legend style="display: inline-block;width: 25em; "><b>WooCommerce Tax Classes</b></legend><br>
<?php
$vend_to_wc_implode_tax['tax_name'][] = 'standard-tax';
$tax_classes_list = array_map("rtrim", explode("\n", get_option('woocommerce_tax_classes')));
foreach ($tax_classes_list as $value) {
$taxexplode = explode(" ", strtolower($value));
$vend_to_wc_implode_tax['tax_name'][] = implode("-", $taxexplode);
}
foreach ($taxes['taxes'] as $select_tax) {
?>
<li> <legend style="display: inline-block;width: 8em; float: left"><?php echo $select_tax['name']; ?> </legend>
<legend style="display: inline-block;width: 3em; float: left">=></legend>
<legend style="display: inline-block;width: 25em; "><select style="margin-top: -5px" name="vend_to_wc_tax[]">
<?php
foreach ($vend_to_wc_implode_tax['tax_name'] as $tax) {
if (in_array($select_tax['id'] . '|' . $tax, $taxes_all)) {
$selected = "selected";
} else {
$selected = "";
}
echo '<option value="' . $select_tax['id'] . '|' . $tax . '" ' . $selected . '>' . $tax . '</option>';
}
?>
</select></legend></li><?php } ?> </ul></td>
<?php
} else {
?><span style='color:red; '><?php echo 'Error in getting Taxes : No Getting Expecting Data!!<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Taxes : ' . $taxes['userMessage'] . '<br>' ?></span><?php
}
}
?>
</td>
</tr>
<!------------------------------------------------------------------ Payment Mapping vend_to_wc---------------------------------------->
<tr valign="top">
<th class="titledesc">Payment mapping<a href="https://www.linksync.com/help/woocommerce"><img title="When syncing orders, both Vend and WooCommerce have their own payment methods - use these Payment Mapping settings to 'map' the Vend payment methods with those in your WooCommerce store." style="margin-bottom: -4px;margin-left: 4px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></th>
<td class="forminp forminp-checkbox">
<?php
#Check for the Payment
if (isset($payment) && !empty($payment)) {
if (!isset($payment['errorCode'])) {
if (isset($payment['paymentTypes'])) {
$all_payment = get_option('vend_to_wc_payments');
$payment_all = explode(',', $all_payment);
$payment_gatways = $gatway->payment_gateways();
?><ul><legend style="display: inline-block;width: 8em; float: left"> <b>Vend Payment</b></legend> <legend style="display: inline-block;width: 3em; float: left">=></legend> <legend style="display: inline-block;width: 25em; "><b>WooCommerce Payment Gateways</b></legend><br>
<?php foreach ($payment['paymentTypes'] as $payment_mapping) {
?><li> <legend style="display: inline-block;width: 8em; float: left"><?php echo $payment_mapping['name']; ?></legend>
<legend style="display: inline-block;width: 3em; float: left">=></legend>
<legend style="display: inline-block;width: 25em; "><select style="margin-top: -5px" name="vend_to_wc_payments[]">
<?php
foreach ($payment_gatways as $gatways) {
if ($gatways->enabled == 'yes') {
if (in_array($payment_mapping['id'] . '|' . $gatways->title, $payment_all)) {
$selected = "selected";
} else {
$selected = "";
}
echo '<option value="' . $payment_mapping['id'] . '|' . $gatways->title . '" ' . $selected . '>' . $gatways->title . '</option>';
}
}
?>
</select></legend>
</li><?php } ?></ul>
<?php } else {
?><span style='color:red; '><?php echo 'Error in getting Payment : No Getting Expecting Data!!<br>' ?></span><?php
}
} else {
?><span style='color:red; '><?php echo 'Error in getting Payment : ' . $payment['userMessage'] . '<br>' ?></span><?php
}
}
?> </td>
</tr>
<tr valign="top">
<th class="titledesc">Customer Import </th>
<td class="forminp forminp-checkbox">
<legend style="display: inline-block;width: 25em; "> <input type="radio" checked <?php echo (get_option('vend_to_wc_customer') == 'customer_data' ? 'checked' : ''); ?> value="customer_data" name="vend_to_wc_customer" />Import Customer data<a href="https://www.linksync.com/help/woocommerce"><img title="Select this option if you'd like customer data, such as name, email address and shipping and billing address, to be included when importing orders from Vend." style="margin-left: 4px;margin-bottom: -3px;"src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a></legend><br>
<legend style="display: inline-block;width: 25em; "><input type="radio" <?php echo (get_option('vend_to_wc_customer') == 'guest' ? 'checked' : ''); ?> value="guest" name="vend_to_wc_customer" />Import as 'Guest'<a href="https://www.linksync.com/help/woocommerce"><img title="Select this option if you're not interested in including the customer information when importing orders from Vend." style="margin-left: 4px;margin-bottom: -3px;" src="../wp-content/plugins/linksync/img/help.png" height="16" width="16"></a><br/><br/>
</legend>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p class="wc_t" style="text-align: center;"><input class="button button-primary button-large" type="submit" name="save_order_sync_setting" value="Save Changes"></p>
</form>
<script>
var linksync_jQuery=jQuery.noConflict( true );
linksync_jQuery(document).ready(function() {
linksync_jQuery("input[name='order_sync_type']").click(function() {
if (linksync_jQuery("#disabled_sync_id").is(":checked")) {
linksync_jQuery('#order_sync_setting').slideUp(500);
} else if (linksync_jQuery("#wc_to_vend_sync_id").is(":checked")) {
linksync_jQuery('#order_sync_wc_to_vend').slideDown(500);
linksync_jQuery('#order_sync_vend_to_wc').slideUp(500);
linksync_jQuery('#order_sync_setting').slideDown(500);
} else if (linksync_jQuery("#vend_to_wc_sync_id").is(":checked")) {
linksync_jQuery('#order_sync_vend_to_wc').slideDown(500);
linksync_jQuery('#order_sync_wc_to_vend').slideUp(500);
linksync_jQuery('#order_sync_setting').slideDown(500);
} else {
linksync_jQuery('#order_sync_setting').slideDown(500);
linksync_jQuery('#order_sync_wc_to_vend').slideDown(500);
linksync_jQuery('#order_sync_vend_to_wc').slideDown(500);
}
});
if (linksync_jQuery(".outlet_class").is(":checked")) {
<?php if (!empty($outletDb)) { ?>
linksync_jQuery(".check").hide();
linksync_jQuery("#" + "<?php echo $outletDb; ?>").fadeIn(500);
<?php } else { ?>
var outlet = linksync_jQuery(".outlet_class").val();
linksync_jQuery(".check").fadeOut(500);
linksync_jQuery("#" + outlet).fadeIn(500);
<?php } ?>
}
linksync_jQuery('.outlet_class').click(function() {
var outlet = this.value;
linksync_jQuery(".check").hide();
linksync_jQuery("#" + outlet).fadeIn(500);
});
});
</script>