Version Description
- Fix: woocommerce checkout address 2 field required/optional
- Fix: woocommerce checkout address removed required alert
Download this release
Release Info
| Developer | quadlayers |
| Plugin | |
| Version | 4.3.7 |
| Comparing to | |
| See all releases | |
Code changes from version 4.3.6 to 4.3.7
- changelog.txt +0 -25
- includes/admin.php +510 -502
- includes/install.php +245 -244
- new/fields_handler.php +44 -17
- new/fields_register.php +92 -56
- readme.txt +5 -1
- woocommerce-checkout-manager.php +2 -2
changelog.txt
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
Fifteen ( 15 ) fields types included: Text Input, Text Area, Password, Radio Button, Check Box, Select Options, Date Picker, Time Picker, Color Picker, Heading, Multi-Select, Multi-Checkbox, Country, State, File Picker.
|
| 2 |
-
|
| 3 |
-
Compatible with WPML, WooCommerce Print Invoice & Delivery Note, Store Exporter Deluxe, WooCommerce Order/Customer CSV Export.
|
| 4 |
-
|
| 5 |
-
Sort Orders by Field Name.
|
| 6 |
-
Export Orders by Field Name.
|
| 7 |
-
|
| 8 |
-
Create fields to remove tax
|
| 9 |
-
Create fields to add additional amount
|
| 10 |
-
Display Payment Method and Shipping Method used by customer.
|
| 11 |
-
Disable any added field from Checkout details page and Order Receipt.
|
| 12 |
-
|
| 13 |
-
DatePicker: Change the default format (dd-mm-yy), Set Minimum Date and Maximum Date, Disable days in the week (Sun – Sat).
|
| 14 |
-
TimePicker: Includes restriction of both start and end hours, set the minutes interval and manually input labels.
|
| 15 |
-
Display Order Time.
|
| 16 |
-
|
| 17 |
-
Re-position the added fields: Before Shipping Form, After Shipping Form, Before Billing Form, After Billing Form or After Order Notes
|
| 18 |
-
|
| 19 |
-
= 4.4.0 Beta =
|
| 20 |
-
* Improvement: woocommerce order upload rebuilt
|
| 21 |
-
* Improvement: woocommerce checkout upload rebuilt
|
| 22 |
-
* Improvement: woocommerce order admin upload rebuilt
|
| 23 |
-
* Improvement: woocommerce register fields rebuilt
|
| 24 |
-
* Improvement: woocommerce register fields rebuilt
|
| 25 |
-
* Fix: woocommerce checkout additional fields required
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin.php
CHANGED
|
@@ -432,6 +432,7 @@ function wooccm_options_page() {
|
|
| 432 |
|
| 433 |
case 'country':
|
| 434 |
$defaults2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
|
|
|
| 435 |
break;
|
| 436 |
|
| 437 |
case 'first_name':
|
|
@@ -455,6 +456,7 @@ function wooccm_options_page() {
|
|
| 455 |
case 'address_2':
|
| 456 |
$defaults2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 457 |
$defaults2['shipping_buttons'][$ship]['placeholder'] = __('Apartment, suite, unit etc. (optional)', 'woocommerce-checkout-manager');
|
|
|
|
| 458 |
break;
|
| 459 |
|
| 460 |
case 'city':
|
|
@@ -464,6 +466,7 @@ function wooccm_options_page() {
|
|
| 464 |
|
| 465 |
case 'state':
|
| 466 |
$defaults2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
|
|
|
| 467 |
break;
|
| 468 |
}
|
| 469 |
|
|
@@ -498,6 +501,7 @@ function wooccm_options_page() {
|
|
| 498 |
|
| 499 |
case 'country':
|
| 500 |
$defaults3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
|
|
|
| 501 |
break;
|
| 502 |
|
| 503 |
case 'first_name':
|
|
@@ -521,6 +525,8 @@ function wooccm_options_page() {
|
|
| 521 |
case 'address_2':
|
| 522 |
$defaults3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 523 |
$defaults3['billing_buttons'][$bill]['placeholder'] = __('Apartment, suite, unit etc. (optional)', 'woocommerce-checkout-manager');
|
|
|
|
|
|
|
| 524 |
break;
|
| 525 |
|
| 526 |
case 'city':
|
|
@@ -530,6 +536,8 @@ function wooccm_options_page() {
|
|
| 530 |
|
| 531 |
case 'state':
|
| 532 |
$defaults3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
|
|
|
|
|
|
| 533 |
break;
|
| 534 |
|
| 535 |
case 'postcode':
|
|
@@ -931,11 +939,11 @@ function wooccm_options_validate_billing($input) {
|
|
| 931 |
return $input;
|
| 932 |
}
|
| 933 |
|
| 934 |
-
/*function wooccm_admin_notices() {
|
| 935 |
|
| 936 |
// Check the User has the manage_options capability
|
| 937 |
if (current_user_can('manage_options') == false)
|
| 938 |
-
|
| 939 |
|
| 940 |
// @mod - Removed as it tends to blow people Options up...
|
| 941 |
// Data update from legacy (<3.0)
|
|
@@ -944,20 +952,20 @@ function wooccm_options_validate_billing($input) {
|
|
| 944 |
$screen = get_current_screen();
|
| 945 |
|
| 946 |
if (get_option('wooccm_beta_notice') == false) {
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
}
|
| 960 |
-
}*/
|
| 961 |
|
| 962 |
function wooccm_admin_updater_notice() {
|
| 963 |
|
|
@@ -1417,16 +1425,16 @@ function wooccm_admin_edit_order_shipping_details($order) {
|
|
| 1417 |
}
|
| 1418 |
}
|
| 1419 |
|
| 1420 |
-
/*function wooccm_validate_upload_process_customer() {
|
| 1421 |
|
| 1422 |
$options = get_option('wccs_settings');
|
| 1423 |
|
| 1424 |
if (!empty($options['checkness']['enable_file_upload'])) {
|
| 1425 |
-
|
| 1426 |
} else {
|
| 1427 |
-
|
| 1428 |
}
|
| 1429 |
-
}*/
|
| 1430 |
|
| 1431 |
// Check if the customer can upload images
|
| 1432 |
// @mod - This disables the Order Uploaded Files meta box even for Administrators...?
|
|
@@ -1435,17 +1443,17 @@ function wooccm_admin_edit_order_shipping_details($order) {
|
|
| 1435 |
* if (wooccm_validate_upload_process_customer()) {
|
| 1436 |
add_action('woocommerce_view_order', 'wooccm_file_uploader_front_end');
|
| 1437 |
add_action('add_meta_boxes', 'wooccm_admin_edit_order_metaboxes');
|
| 1438 |
-
}*/
|
| 1439 |
|
| 1440 |
-
/*function wooccm_admin_edit_order_metaboxes() {
|
| 1441 |
|
| 1442 |
global $post;
|
| 1443 |
|
| 1444 |
$post_type = 'shop_order';
|
| 1445 |
add_meta_box('woocommerce-order-files', __('Order Uploaded Files', 'woocommerce-checkout-manager'), 'wooccm_admin_edit_order_uploaded_files_meta_box', $post_type, 'normal', 'default');
|
| 1446 |
-
}*/
|
| 1447 |
/*
|
| 1448 |
-
function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
|
| 1449 |
|
| 1450 |
global $wpdb, $thepostid, $theorder, $woocommerce, $post;
|
| 1451 |
|
|
@@ -1461,71 +1469,71 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
|
|
| 1461 |
|
| 1462 |
$post_type = 'attachment';
|
| 1463 |
$args = array(
|
| 1464 |
-
|
| 1465 |
-
|
| 1466 |
-
|
| 1467 |
-
|
| 1468 |
);
|
| 1469 |
$posts = get_posts($args);
|
| 1470 |
// wooccm_error_log( 'posts: ' . print_r( $posts, true ) );
|
| 1471 |
// @mod - Legacy versions were not correctly saving Post Parent so let's do a search if no results were returned
|
| 1472 |
if (empty($posts)) {
|
| 1473 |
|
| 1474 |
-
|
| 1475 |
|
| 1476 |
-
|
| 1477 |
-
|
| 1478 |
-
|
| 1479 |
-
|
| 1480 |
-
|
| 1481 |
-
|
| 1482 |
-
|
| 1483 |
-
|
| 1484 |
-
|
| 1485 |
-
|
| 1486 |
-
|
| 1487 |
-
|
| 1488 |
-
|
| 1489 |
-
|
| 1490 |
-
|
| 1491 |
-
|
| 1492 |
-
|
| 1493 |
-
|
| 1494 |
-
|
| 1495 |
-
|
| 1496 |
-
|
| 1497 |
-
|
| 1498 |
-
|
| 1499 |
-
|
| 1500 |
-
|
| 1501 |
-
|
| 1502 |
-
|
| 1503 |
|
| 1504 |
-
|
| 1505 |
-
|
| 1506 |
-
|
| 1507 |
-
|
| 1508 |
-
|
| 1509 |
-
|
| 1510 |
-
|
| 1511 |
-
|
| 1512 |
-
|
| 1513 |
-
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
| 1517 |
}
|
| 1518 |
// Check if there are any attachments
|
| 1519 |
if (!empty($posts) || !empty($array)) {
|
| 1520 |
-
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
|
| 1524 |
-
|
| 1525 |
-
|
| 1526 |
-
|
| 1527 |
-
|
| 1528 |
-
|
| 1529 |
}
|
| 1530 |
|
| 1531 |
$attachments = array_filter(explode(',', $product_image_gallery));
|
|
@@ -1533,166 +1541,166 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
|
|
| 1533 |
?>
|
| 1534 |
|
| 1535 |
<script type="text/javascript">
|
| 1536 |
-
|
| 1537 |
-
|
| 1538 |
-
|
| 1539 |
-
|
| 1540 |
-
|
| 1541 |
-
|
| 1542 |
-
|
| 1543 |
-
|
| 1544 |
-
|
| 1545 |
-
|
| 1546 |
-
|
| 1547 |
-
|
| 1548 |
-
|
| 1549 |
-
|
| 1550 |
-
|
| 1551 |
-
|
| 1552 |
-
|
| 1553 |
-
|
| 1554 |
</script>
|
| 1555 |
|
| 1556 |
<?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/templates/admin/edit-order-uploads-file_editing_table.css', WOOCCM_PLUGIN_FILE)); ?>
|
| 1557 |
|
| 1558 |
<div class="woocommerce_order_items_wrapper">
|
| 1559 |
-
|
| 1560 |
-
|
| 1561 |
-
|
| 1562 |
-
|
| 1563 |
-
|
| 1564 |
-
|
| 1565 |
-
|
| 1566 |
-
|
| 1567 |
-
|
| 1568 |
-
|
| 1569 |
-
|
| 1570 |
-
|
| 1571 |
-
|
| 1572 |
-
|
| 1573 |
-
|
| 1574 |
-
|
| 1575 |
-
|
| 1576 |
-
|
| 1577 |
-
|
| 1578 |
-
|
| 1579 |
-
|
| 1580 |
-
|
| 1581 |
-
|
| 1582 |
-
|
| 1583 |
-
|
| 1584 |
-
|
| 1585 |
-
|
| 1586 |
-
|
| 1587 |
-
|
| 1588 |
-
|
| 1589 |
-
|
| 1590 |
-
|
| 1591 |
-
|
| 1592 |
-
|
| 1593 |
-
|
| 1594 |
-
|
| 1595 |
-
|
| 1596 |
-
|
| 1597 |
-
|
| 1598 |
-
|
| 1599 |
-
|
| 1600 |
-
|
| 1601 |
-
|
| 1602 |
-
|
| 1603 |
-
|
| 1604 |
-
|
| 1605 |
-
|
| 1606 |
-
|
| 1607 |
-
|
| 1608 |
-
|
| 1609 |
-
|
| 1610 |
-
|
| 1611 |
-
|
| 1612 |
-
|
| 1613 |
-
|
| 1614 |
-
';
|
| 1615 |
-
|
| 1616 |
-
|
| 1617 |
-
|
| 1618 |
-
<tr>
|
| 1619 |
-
|
| 1620 |
-
</tr>';
|
| 1621 |
-
|
| 1622 |
-
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
|
| 1626 |
-
|
| 1627 |
-
|
| 1628 |
-
|
| 1629 |
-
|
| 1630 |
-
|
| 1631 |
-
|
| 1632 |
-
|
| 1633 |
-
|
| 1634 |
-
|
| 1635 |
-
|
| 1636 |
-
|
| 1637 |
</p>
|
| 1638 |
|
| 1639 |
<!-- Edit Order: File upload -->
|
| 1640 |
<script type="text/javascript">
|
| 1641 |
-
|
| 1642 |
-
|
| 1643 |
-
|
| 1644 |
|
| 1645 |
-
|
| 1646 |
|
| 1647 |
-
|
| 1648 |
-
|
| 1649 |
-
|
| 1650 |
-
|
| 1651 |
|
| 1652 |
-
|
| 1653 |
-
|
| 1654 |
-
|
| 1655 |
-
|
| 1656 |
-
|
| 1657 |
-
|
| 1658 |
-
|
| 1659 |
-
|
| 1660 |
-
|
| 1661 |
-
|
| 1662 |
-
|
| 1663 |
-
|
| 1664 |
-
|
| 1665 |
-
|
| 1666 |
-
|
| 1667 |
-
|
| 1668 |
-
|
| 1669 |
-
|
| 1670 |
-
|
| 1671 |
-
|
| 1672 |
-
|
| 1673 |
-
|
| 1674 |
-
|
| 1675 |
-
|
| 1676 |
-
|
| 1677 |
-
|
| 1678 |
-
|
| 1679 |
-
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
|
| 1683 |
-
|
| 1684 |
-
|
| 1685 |
-
|
| 1686 |
-
|
| 1687 |
-
|
| 1688 |
-
|
| 1689 |
-
|
| 1690 |
-
|
| 1691 |
-
|
| 1692 |
|
| 1693 |
-
|
| 1694 |
|
| 1695 |
-
|
| 1696 |
</script>
|
| 1697 |
|
| 1698 |
<input type="button" id="wccm_save_order_submit" class="button button-primary" value="<?php _e('Save Changes', 'woocommerce-checkout-manager'); ?>">
|
|
@@ -1702,12 +1710,12 @@ function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
|
|
| 1702 |
</div>
|
| 1703 |
<!-- .woocommerce_order_items_wrapper -->
|
| 1704 |
<?php
|
| 1705 |
-
}*/
|
| 1706 |
|
| 1707 |
-
/*
|
| 1708 |
* 1326
|
| 1709 |
* front end for user
|
| 1710 |
-
function wooccm_file_uploader_front_end($order_id) {
|
| 1711 |
|
| 1712 |
global $wpdb, $thepostid, $theorder, $woocommerce, $post;
|
| 1713 |
|
|
@@ -1723,240 +1731,240 @@ function wooccm_file_uploader_front_end($order_id) {
|
|
| 1723 |
|
| 1724 |
if (empty($options['checkness']['upload_os']) || ( $order->post_status == $prefix . $options['checkness']['upload_os'] )) {
|
| 1725 |
|
| 1726 |
-
|
| 1727 |
-
|
| 1728 |
-
|
| 1729 |
-
|
| 1730 |
-
|
| 1731 |
-
|
| 1732 |
-
|
| 1733 |
-
|
| 1734 |
-
|
| 1735 |
-
|
| 1736 |
-
|
| 1737 |
-
|
| 1738 |
-
|
| 1739 |
-
|
| 1740 |
-
|
| 1741 |
-
|
| 1742 |
-
|
| 1743 |
-
|
| 1744 |
-
|
| 1745 |
-
|
| 1746 |
-
|
| 1747 |
-
|
| 1748 |
-
|
| 1749 |
-
|
| 1750 |
|
| 1751 |
-
|
| 1752 |
-
|
| 1753 |
-
|
| 1754 |
-
|
| 1755 |
-
|
| 1756 |
-
|
| 1757 |
-
|
| 1758 |
-
|
| 1759 |
-
|
| 1760 |
-
|
| 1761 |
-
|
| 1762 |
-
|
| 1763 |
-
|
| 1764 |
-
|
| 1765 |
-
|
| 1766 |
-
|
| 1767 |
-
|
|
|
|
|
|
|
|
|
|
| 1768 |
|
| 1769 |
-
|
| 1770 |
-
</script>
|
| 1771 |
|
| 1772 |
-
|
| 1773 |
-
|
| 1774 |
-
|
| 1775 |
-
|
| 1776 |
-
|
| 1777 |
-
|
| 1778 |
-
|
| 1779 |
-
|
| 1780 |
-
|
| 1781 |
-
|
| 1782 |
-
|
| 1783 |
-
|
| 1784 |
-
|
| 1785 |
-
|
| 1786 |
-
|
| 1787 |
-
|
| 1788 |
-
|
| 1789 |
-
|
| 1790 |
-
|
| 1791 |
-
if (!empty($attachments)) {
|
| 1792 |
-
foreach ($attachments as $attachment_id) {
|
| 1793 |
|
| 1794 |
-
|
| 1795 |
-
|
| 1796 |
-
|
| 1797 |
-
|
| 1798 |
|
| 1799 |
-
|
| 1800 |
|
| 1801 |
-
|
| 1802 |
-
|
| 1803 |
|
| 1804 |
-
|
| 1805 |
-
|
| 1806 |
|
| 1807 |
-
|
| 1808 |
|
| 1809 |
-
|
| 1810 |
-
|
| 1811 |
-
|
| 1812 |
|
| 1813 |
-
|
| 1814 |
-
|
| 1815 |
|
| 1816 |
-
|
| 1817 |
-
|
| 1818 |
-
|
| 1819 |
-
|
| 1820 |
-
|
| 1821 |
-
|
| 1822 |
-
|
| 1823 |
-
|
| 1824 |
-
|
| 1825 |
-
|
| 1826 |
-
|
| 1827 |
-
|
| 1828 |
-
|
| 1829 |
-
|
| 1830 |
-
|
| 1831 |
-
|
| 1832 |
-
|
| 1833 |
-
|
| 1834 |
-
|
| 1835 |
-
|
| 1836 |
-
|
| 1837 |
-
|
| 1838 |
-
|
| 1839 |
-
|
| 1840 |
-
';
|
| 1841 |
-
|
| 1842 |
-
|
| 1843 |
-
|
| 1844 |
-
|
| 1845 |
-
|
| 1846 |
-
|
| 1847 |
-
|
| 1848 |
-
|
| 1849 |
-
|
| 1850 |
|
| 1851 |
-
|
| 1852 |
|
| 1853 |
-
|
| 1854 |
-
|
| 1855 |
-
|
| 1856 |
-
|
| 1857 |
-
|
| 1858 |
|
| 1859 |
-
|
| 1860 |
|
| 1861 |
-
|
| 1862 |
-
|
| 1863 |
-
|
| 1864 |
-
|
| 1865 |
-
<!-- Edit Order: File upload -->
|
| 1866 |
-
<script type="text/javascript">
|
| 1867 |
-
jQuery(document).ready(function($){
|
| 1868 |
|
| 1869 |
-
|
| 1870 |
|
| 1871 |
-
|
| 1872 |
|
| 1873 |
-
|
| 1874 |
-
|
| 1875 |
-
|
| 1876 |
-
|
| 1877 |
|
| 1878 |
-
|
| 1879 |
-
|
| 1880 |
-
|
| 1881 |
|
| 1882 |
-
|
| 1883 |
-
|
| 1884 |
-
|
| 1885 |
-
|
| 1886 |
-
|
| 1887 |
-
|
| 1888 |
-
|
| 1889 |
-
|
| 1890 |
|
| 1891 |
-
|
| 1892 |
-
|
| 1893 |
-
|
| 1894 |
-
|
| 1895 |
-
|
| 1896 |
-
|
| 1897 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1898 |
|
| 1899 |
-
var length = ' . $length . ';
|
| 1900 |
-
var file_array = ' . wooccm_js_array($file_types) . ';
|
| 1901 |
-
var wooempt = "' . implode(',', $file_types) . '";
|
| 1902 |
-
|
| 1903 |
-
for ( i = 0; i < length; i++ ) {
|
| 1904 |
-
file = this.files[i];
|
| 1905 |
-
for(x=0; x < ' . $number_of_types . '; x++){
|
| 1906 |
-
if( !wooempt || file.type.match(file_array[x]) ) {
|
| 1907 |
-
if (formdata) {
|
| 1908 |
-
formdata.append("files_wccm[]",file);
|
| 1909 |
-
}
|
| 1910 |
-
}
|
| 1911 |
-
}
|
| 1912 |
-
}
|
| 1913 |
-
|
| 1914 |
-
if (formdata) {
|
| 1915 |
-
$.ajax({
|
| 1916 |
-
url: "' . admin_url('/admin-ajax.php?action=wccs_upload_file_func&order_id=' . $order_id . '&name=files_wccm') . '",
|
| 1917 |
-
type: "POST",
|
| 1918 |
-
data: formdata,
|
| 1919 |
-
processData: false,
|
| 1920 |
-
contentType: false,
|
| 1921 |
-
success: function (res) {
|
| 1922 |
-
$("#files_wccm").show();
|
| 1923 |
-
|
| 1924 |
-
$.ajax({
|
| 1925 |
-
url: "' . $order->get_view_order_url() . '",
|
| 1926 |
-
data: {},
|
| 1927 |
-
success: function (data) {
|
| 1928 |
-
$("div.woocommerce_order_items_wrapper.front_end").html($(data).find("div.woocommerce_order_items_wrapper.front_end"));
|
| 1929 |
-
jQuery("#wccm_uploader_select").unblock();
|
| 1930 |
-
},
|
| 1931 |
-
dataType: "html"
|
| 1932 |
-
});
|
| 1933 |
-
|
| 1934 |
-
}
|
| 1935 |
-
});
|
| 1936 |
-
}
|
| 1937 |
-
}, false);
|
| 1938 |
-
}
|
| 1939 |
-
());
|
| 1940 |
-
});
|
| 1941 |
-
</script>';
|
| 1942 |
-
// end script
|
| 1943 |
-
// ------------
|
| 1944 |
}
|
| 1945 |
-
}
|
| 1946 |
-
|
| 1947 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1948 |
|
| 1949 |
$name = ( isset($_REQUEST['name']) ? $_REQUEST['name'] : false );
|
| 1950 |
$order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
|
| 1951 |
|
| 1952 |
if (empty($name)) {
|
| 1953 |
-
|
| 1954 |
-
|
| 1955 |
}
|
| 1956 |
|
| 1957 |
if (empty($order_id)) {
|
| 1958 |
-
|
| 1959 |
-
|
| 1960 |
}
|
| 1961 |
|
| 1962 |
global $wpdb, $woocommerce, $post; // this is how you get access to the database
|
|
@@ -1976,94 +1984,94 @@ jQuery(document).ready(function($){
|
|
| 1976 |
// $upload_overrides = array( 'test_form' => false );
|
| 1977 |
|
| 1978 |
if (!empty($files['name'])) {
|
| 1979 |
-
|
| 1980 |
-
|
| 1981 |
-
|
| 1982 |
-
|
| 1983 |
-
|
| 1984 |
-
|
| 1985 |
-
|
| 1986 |
-
|
| 1987 |
-
|
| 1988 |
-
|
| 1989 |
|
| 1990 |
-
|
| 1991 |
-
|
| 1992 |
-
|
| 1993 |
-
|
| 1994 |
-
|
| 1995 |
-
|
| 1996 |
-
|
| 1997 |
|
| 1998 |
-
|
| 1999 |
-
|
| 2000 |
|
| 2001 |
-
|
| 2002 |
-
|
| 2003 |
-
|
| 2004 |
-
|
| 2005 |
-
|
| 2006 |
|
| 2007 |
-
|
| 2008 |
-
|
| 2009 |
-
|
| 2010 |
-
|
| 2011 |
-
|
| 2012 |
-
|
| 2013 |
-
|
| 2014 |
-
|
| 2015 |
|
| 2016 |
-
|
| 2017 |
|
| 2018 |
-
|
| 2019 |
-
|
| 2020 |
|
| 2021 |
-
|
| 2022 |
-
|
| 2023 |
-
|
| 2024 |
|
| 2025 |
-
|
| 2026 |
-
|
| 2027 |
-
|
| 2028 |
-
|
| 2029 |
|
| 2030 |
-
|
| 2031 |
-
|
| 2032 |
-
|
| 2033 |
-
|
| 2034 |
-
|
| 2035 |
-
|
| 2036 |
|
| 2037 |
-
|
| 2038 |
|
| 2039 |
-
|
| 2040 |
-
|
| 2041 |
-
|
| 2042 |
-
|
| 2043 |
-
|
| 2044 |
-
|
| 2045 |
-
|
| 2046 |
-
|
| 2047 |
-
|
| 2048 |
-
|
| 2049 |
-
|
| 2050 |
-
|
| 2051 |
-
|
| 2052 |
-
|
| 2053 |
|
| 2054 |
-
|
| 2055 |
|
| 2056 |
-
|
| 2057 |
-
|
| 2058 |
-
|
| 2059 |
-
|
| 2060 |
-
|
| 2061 |
-
|
| 2062 |
} else {
|
| 2063 |
-
|
| 2064 |
}
|
| 2065 |
die();
|
| 2066 |
-
}*/
|
| 2067 |
|
| 2068 |
//1326
|
| 2069 |
//add_action("wp_ajax_wccs_upload_file_func", "wccs_upload_file_func_callback");
|
|
@@ -2073,7 +2081,7 @@ jQuery(document).ready(function($){
|
|
| 2073 |
* function wooccm_set_html_content_type() {
|
| 2074 |
|
| 2075 |
return 'text/html';
|
| 2076 |
-
}*/
|
| 2077 |
|
| 2078 |
function wooccm_js_str($s) {
|
| 2079 |
|
| 432 |
|
| 433 |
case 'country':
|
| 434 |
$defaults2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 435 |
+
$defaults2['shipping_buttons'][$ship]['type'] = 'wooccmcountry';
|
| 436 |
break;
|
| 437 |
|
| 438 |
case 'first_name':
|
| 456 |
case 'address_2':
|
| 457 |
$defaults2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 458 |
$defaults2['shipping_buttons'][$ship]['placeholder'] = __('Apartment, suite, unit etc. (optional)', 'woocommerce-checkout-manager');
|
| 459 |
+
$defaults2['shipping_buttons'][$ship]['required'] = false;
|
| 460 |
break;
|
| 461 |
|
| 462 |
case 'city':
|
| 466 |
|
| 467 |
case 'state':
|
| 468 |
$defaults2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 469 |
+
$defaults2['shipping_buttons'][$ship]['type'] = 'wooccmstate';
|
| 470 |
break;
|
| 471 |
}
|
| 472 |
|
| 501 |
|
| 502 |
case 'country':
|
| 503 |
$defaults3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 504 |
+
$defaults3['billing_buttons'][$bill]['type'] = 'wooccmcountry';
|
| 505 |
break;
|
| 506 |
|
| 507 |
case 'first_name':
|
| 525 |
case 'address_2':
|
| 526 |
$defaults3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 527 |
$defaults3['billing_buttons'][$bill]['placeholder'] = __('Apartment, suite, unit etc. (optional)', 'woocommerce-checkout-manager');
|
| 528 |
+
$defaults3['billing_buttons'][$bill]['checkbox'] = false;
|
| 529 |
+
|
| 530 |
break;
|
| 531 |
|
| 532 |
case 'city':
|
| 536 |
|
| 537 |
case 'state':
|
| 538 |
$defaults3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 539 |
+
$defaults3['billing_buttons'][$bill]['type'] = 'wooccmstate';
|
| 540 |
+
|
| 541 |
break;
|
| 542 |
|
| 543 |
case 'postcode':
|
| 939 |
return $input;
|
| 940 |
}
|
| 941 |
|
| 942 |
+
/* function wooccm_admin_notices() {
|
| 943 |
|
| 944 |
// Check the User has the manage_options capability
|
| 945 |
if (current_user_can('manage_options') == false)
|
| 946 |
+
return;
|
| 947 |
|
| 948 |
// @mod - Removed as it tends to blow people Options up...
|
| 949 |
// Data update from legacy (<3.0)
|
| 952 |
$screen = get_current_screen();
|
| 953 |
|
| 954 |
if (get_option('wooccm_beta_notice') == false) {
|
| 955 |
+
$beta_url = 'https://www.visser.com.au/plugins/woocommerce-checkout-manager/#beta';
|
| 956 |
+
$support_url = 'https://wordpress.org/support/plugin/woocommerce-checkout-manager#postform';
|
| 957 |
+
$dismiss_url = add_query_arg(array('action' => 'wooccm_dismiss_beta_notice', '_wpnonce' => wp_create_nonce('wooccm_dismiss_beta_notice')));
|
| 958 |
+
|
| 959 |
+
$message = '<span style="float:right;"><a href="' . $dismiss_url . '" class="woocommerce-message-close notice-dismiss">' . __('Dismiss', 'woocommerce-checkout-manager') . '</a></span>';
|
| 960 |
+
$message .= __('<strong>WooCommerce Checkout Manager Notice:</strong> We urgently need developers, integrators and interested store owners to test early Plugin releases and provide feedback to help stabilise the 4.0+ series. Can you help?', 'woocommerce-checkout-manager');
|
| 961 |
+
$message .= '
|
| 962 |
+
<p class="submit">
|
| 963 |
+
<a href="' . $beta_url . '" target="_blank" class="button-primary button-hero">' . __('Join the Developers list', 'woocommerce-checkout-manager') . '</a>
|
| 964 |
+
<a href="' . $support_url . '" target="_blank" class="button-secondary button-hero">' . __('Send feedback', 'woocommerce-checkout-manager') . '</a>
|
| 965 |
+
</p>';
|
| 966 |
+
echo wooccm_admin_notice_html($message);
|
| 967 |
}
|
| 968 |
+
} */
|
| 969 |
|
| 970 |
function wooccm_admin_updater_notice() {
|
| 971 |
|
| 1425 |
}
|
| 1426 |
}
|
| 1427 |
|
| 1428 |
+
/* function wooccm_validate_upload_process_customer() {
|
| 1429 |
|
| 1430 |
$options = get_option('wccs_settings');
|
| 1431 |
|
| 1432 |
if (!empty($options['checkness']['enable_file_upload'])) {
|
| 1433 |
+
return true;
|
| 1434 |
} else {
|
| 1435 |
+
return false;
|
| 1436 |
}
|
| 1437 |
+
} */
|
| 1438 |
|
| 1439 |
// Check if the customer can upload images
|
| 1440 |
// @mod - This disables the Order Uploaded Files meta box even for Administrators...?
|
| 1443 |
* if (wooccm_validate_upload_process_customer()) {
|
| 1444 |
add_action('woocommerce_view_order', 'wooccm_file_uploader_front_end');
|
| 1445 |
add_action('add_meta_boxes', 'wooccm_admin_edit_order_metaboxes');
|
| 1446 |
+
} */
|
| 1447 |
|
| 1448 |
+
/* function wooccm_admin_edit_order_metaboxes() {
|
| 1449 |
|
| 1450 |
global $post;
|
| 1451 |
|
| 1452 |
$post_type = 'shop_order';
|
| 1453 |
add_meta_box('woocommerce-order-files', __('Order Uploaded Files', 'woocommerce-checkout-manager'), 'wooccm_admin_edit_order_uploaded_files_meta_box', $post_type, 'normal', 'default');
|
| 1454 |
+
} */
|
| 1455 |
/*
|
| 1456 |
+
function wooccm_admin_edit_order_uploaded_files_meta_box($post) {
|
| 1457 |
|
| 1458 |
global $wpdb, $thepostid, $theorder, $woocommerce, $post;
|
| 1459 |
|
| 1469 |
|
| 1470 |
$post_type = 'attachment';
|
| 1471 |
$args = array(
|
| 1472 |
+
'post_type' => $post_type,
|
| 1473 |
+
'numberposts' => -1,
|
| 1474 |
+
'post_status' => null,
|
| 1475 |
+
'post_parent' => $order_id
|
| 1476 |
);
|
| 1477 |
$posts = get_posts($args);
|
| 1478 |
// wooccm_error_log( 'posts: ' . print_r( $posts, true ) );
|
| 1479 |
// @mod - Legacy versions were not correctly saving Post Parent so let's do a search if no results were returned
|
| 1480 |
if (empty($posts)) {
|
| 1481 |
|
| 1482 |
+
$meta_keys = array();
|
| 1483 |
|
| 1484 |
+
// Additional section
|
| 1485 |
+
$options = get_option('wccs_settings');
|
| 1486 |
+
$buttons = ( isset($options['buttons']) ? $options['buttons'] : false );
|
| 1487 |
+
if (!empty($buttons)) {
|
| 1488 |
+
foreach ($buttons as $btn) {
|
| 1489 |
+
if ($btn['type'] == 'wooccmupload')
|
| 1490 |
+
$meta_keys[] = $btn['cow'];
|
| 1491 |
+
}
|
| 1492 |
+
}
|
| 1493 |
+
// Billing section
|
| 1494 |
+
$options = get_option('wccs_settings3');
|
| 1495 |
+
$buttons = ( isset($options['billing_buttons']) ? $options['billing_buttons'] : false );
|
| 1496 |
+
if (!empty($buttons)) {
|
| 1497 |
+
foreach ($buttons as $btn) {
|
| 1498 |
+
if ($btn['type'] == 'wooccmupload')
|
| 1499 |
+
$meta_keys[] = sprintf('_billing_%s', $btn['cow']);
|
| 1500 |
+
}
|
| 1501 |
+
}
|
| 1502 |
+
// Shipping section
|
| 1503 |
+
$options = get_option('wccs_settings2');
|
| 1504 |
+
$buttons = ( isset($options['shipping_buttons']) ? $options['shipping_buttons'] : false );
|
| 1505 |
+
if (!empty($buttons)) {
|
| 1506 |
+
foreach ($buttons as $btn) {
|
| 1507 |
+
if ($btn['type'] == 'wooccmupload')
|
| 1508 |
+
$meta_keys[] = sprintf('_shipping_%s', $btn['cow']);
|
| 1509 |
+
}
|
| 1510 |
+
}
|
| 1511 |
|
| 1512 |
+
if (!empty($meta_keys)) {
|
| 1513 |
+
$values = array();
|
| 1514 |
+
// Check the Order for these meta keys
|
| 1515 |
+
foreach ($meta_keys as $meta_key) {
|
| 1516 |
+
$value = get_post_meta($order_id, $meta_key, true);
|
| 1517 |
+
if (!empty($value)) {
|
| 1518 |
+
if (is_array($value))
|
| 1519 |
+
$array[] = implode(',', $value);
|
| 1520 |
+
else
|
| 1521 |
+
$array[] = $value;
|
| 1522 |
+
}
|
| 1523 |
+
}
|
| 1524 |
+
}
|
| 1525 |
}
|
| 1526 |
// Check if there are any attachments
|
| 1527 |
if (!empty($posts) || !empty($array)) {
|
| 1528 |
+
if (!empty($posts)) {
|
| 1529 |
+
foreach ($posts as $attachment) {
|
| 1530 |
+
$array[] = $attachment->ID;
|
| 1531 |
+
}
|
| 1532 |
+
}
|
| 1533 |
+
$default_wccm_values = implode(',', $array);
|
| 1534 |
+
$product_image_gallery = implode(',', $array);
|
| 1535 |
+
// wooccm_error_log( 'default_wccm_values: ' . print_r( $default_wccm_values, true ) );
|
| 1536 |
+
// wooccm_error_log( 'product_image_gallery: ' . print_r( $product_image_gallery, true ) );
|
| 1537 |
}
|
| 1538 |
|
| 1539 |
$attachments = array_filter(explode(',', $product_image_gallery));
|
| 1541 |
?>
|
| 1542 |
|
| 1543 |
<script type="text/javascript">
|
| 1544 |
+
jQuery(document).ready(function ($) {
|
| 1545 |
+
|
| 1546 |
+
$('#wccm_save_order_submit').click(function () {
|
| 1547 |
+
$(".wccm_results").html("<?php _e('Saving, please wait...', 'woocommerce-checkout-manager'); ?>");
|
| 1548 |
+
var data = {
|
| 1549 |
+
action: 'update_attachment_wccm',
|
| 1550 |
+
post_id: '<?php echo $post->ID; ?>',
|
| 1551 |
+
product_image_gallery: $('#product_image_gallery').val(),
|
| 1552 |
+
wccm_default_keys_load: $('#wccm_default_keys_load').val()
|
| 1553 |
+
};
|
| 1554 |
+
|
| 1555 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
| 1556 |
+
$.post(ajaxurl, data, function (response) {
|
| 1557 |
+
$(".wccm_results").html(response);
|
| 1558 |
+
});
|
| 1559 |
+
});
|
| 1560 |
+
|
| 1561 |
+
});
|
| 1562 |
</script>
|
| 1563 |
|
| 1564 |
<?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/templates/admin/edit-order-uploads-file_editing_table.css', WOOCCM_PLUGIN_FILE)); ?>
|
| 1565 |
|
| 1566 |
<div class="woocommerce_order_items_wrapper">
|
| 1567 |
+
<table class="woocommerce_order_items back_end">
|
| 1568 |
+
|
| 1569 |
+
<thead>
|
| 1570 |
+
<tr>
|
| 1571 |
+
<th nowrap>
|
| 1572 |
+
<attr title="<?php _e('Attachment ID', 'woocommerce-checkout-manager'); ?>"><?php _e('ID', 'woocommerce-checkout-manager'); ?></attr>
|
| 1573 |
+
</th>
|
| 1574 |
+
<th><?php _e('Image', 'woocommerce-checkout-manager'); ?></th>
|
| 1575 |
+
<th><?php _e('Filename', 'woocommerce-checkout-manager'); ?></th>
|
| 1576 |
+
<th><?php _e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
|
| 1577 |
+
<th><?php _e('Extension', ' woocommerce-checkout-manager'); ?></th>
|
| 1578 |
+
<th class="column-actions"><?php _e('Actions', 'woocommerce-checkout-manager'); ?></th>
|
| 1579 |
+
</tr>
|
| 1580 |
+
</thead>
|
| 1581 |
+
|
| 1582 |
+
<tbody class="product_images">
|
| 1583 |
+
<?php
|
| 1584 |
+
if (!empty($attachments)) {
|
| 1585 |
+
foreach ($attachments as $attachment_id) {
|
| 1586 |
+
|
| 1587 |
+
$image_attributes = wp_get_attachment_url($attachment_id);
|
| 1588 |
+
$image_attributes2 = wp_get_attachment_image_src($attachment_id);
|
| 1589 |
+
$filename = basename($image_attributes);
|
| 1590 |
+
$wp_filetype = wp_check_filetype($filename);
|
| 1591 |
+
|
| 1592 |
+
$value_declear = array_diff(explode(',', $default_wccm_values), explode(',', $attachment_id));
|
| 1593 |
+
|
| 1594 |
+
echo '
|
| 1595 |
+
<tr class="image wccm_filesli wccmv_' . esc_attr($attachment_id) . '">
|
| 1596 |
+
<script type="text/javascript">
|
| 1597 |
+
jQuery(document).ready(function(){
|
| 1598 |
+
jQuery(".wccmx_' . esc_attr($attachment_id) . '").click(function(){
|
| 1599 |
+
|
| 1600 |
+
jQuery(".wccmv_' . esc_attr($attachment_id) . '").hide();
|
| 1601 |
+
jQuery("#product_image_gallery").val(jQuery("#product_image_gallery").val().replace("' . esc_attr($attachment_id) . '", ""));
|
| 1602 |
+
|
| 1603 |
+
});
|
| 1604 |
+
});
|
| 1605 |
+
</script>
|
| 1606 |
+
<td>' . $attachment_id . '</td>
|
| 1607 |
+
<td>' . wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), false)) . '</td>
|
| 1608 |
+
<td>' . wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)) . '</td>
|
| 1609 |
+
<td>';
|
| 1610 |
+
if ($image_attributes2[1] == '') {
|
| 1611 |
+
echo '-';
|
| 1612 |
+
} else {
|
| 1613 |
+
echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
|
| 1614 |
+
}
|
| 1615 |
+
echo '</td>
|
| 1616 |
+
<td>' . strtoupper($wp_filetype['ext']) . '</td>
|
| 1617 |
+
<td class="column-actions" nowrap>
|
| 1618 |
+
<a href="' . $image_attributes2[0] . '" target="_blank" class="button">' . __('Download', 'woocommerce-checkout-manager') . '</a>
|
| 1619 |
+
<a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete', 'woocommerce-checkout-manager') . '">' . __('Delete', 'woocommerce-checkout-manager') . '</a>
|
| 1620 |
+
</td>
|
| 1621 |
+
</tr>
|
| 1622 |
+
';
|
| 1623 |
+
}
|
| 1624 |
+
} else {
|
| 1625 |
+
echo '
|
| 1626 |
+
<tr>
|
| 1627 |
+
<td colspan="6" style="text-align:left;">' . __('No files have been uploaded to this Order.', 'woocommerce-checkout-manager') . '</td>
|
| 1628 |
+
</tr>';
|
| 1629 |
+
}
|
| 1630 |
+
?>
|
| 1631 |
+
</tbody>
|
| 1632 |
+
</table>
|
| 1633 |
+
<input type="hidden" class="wccm_add_to_list" id="product_image_gallery" name="product_image_gallery" value="<?php echo esc_attr($product_image_gallery); ?>" />
|
| 1634 |
+
<input type="hidden" id="wccm_default_keys_load" name="wccm_default_keys_load" value="<?php echo esc_attr($default_wccm_values); ?>" />
|
| 1635 |
+
<!-- .woocommerce_order_items -->
|
| 1636 |
+
|
| 1637 |
+
<p class="add_product_images hide-if-no-js">
|
| 1638 |
+
<form method="POST" action="">
|
| 1639 |
+
<span class="btn button-primary wccm_add_order_link fileinput-button">
|
| 1640 |
+
<span><?php _e('Add Order Files', 'woocommerce-checkout-manager'); ?></span>
|
| 1641 |
+
<input type="file" name="files_wccm" id="files_wccm" multiple />
|
| 1642 |
+
<button type="button" id="files_button_wccm"><?php _e('Upload Files!', 'woocommerce-checkout-manager'); ?></button>
|
| 1643 |
+
</span>
|
| 1644 |
+
</form>
|
| 1645 |
</p>
|
| 1646 |
|
| 1647 |
<!-- Edit Order: File upload -->
|
| 1648 |
<script type="text/javascript">
|
| 1649 |
+
jQuery(document).ready(function ($) {
|
| 1650 |
+
(
|
| 1651 |
+
function post_image_content() {
|
| 1652 |
|
| 1653 |
+
var input = document.getElementById("files_wccm"), formdata = false;
|
| 1654 |
|
| 1655 |
+
if (window.FormData) {
|
| 1656 |
+
formdata = new FormData();
|
| 1657 |
+
document.getElementById("files_button_wccm").style.display = "none";
|
| 1658 |
+
}
|
| 1659 |
|
| 1660 |
+
input.addEventListener("change", function (evt) {
|
| 1661 |
+
|
| 1662 |
+
$(".wccm_results").html("Uploading, please wait....");
|
| 1663 |
+
|
| 1664 |
+
var i = 0, len = this.files.length, img, reader, file;
|
| 1665 |
+
|
| 1666 |
+
for (; i < len; i++) {
|
| 1667 |
+
file = this.files[i];
|
| 1668 |
+
if (formdata) {
|
| 1669 |
+
formdata.append("files_wccm[]", file);
|
| 1670 |
+
}
|
| 1671 |
+
}
|
| 1672 |
+
|
| 1673 |
+
if (formdata) {
|
| 1674 |
+
$.ajax({
|
| 1675 |
+
url: "<?php echo admin_url('/admin-ajax.php?action=wccs_upload_file_func&order_id=' . $order_id . '&name=files_wccm'); ?>",
|
| 1676 |
+
type: "POST",
|
| 1677 |
+
data: formdata,
|
| 1678 |
+
processData: false,
|
| 1679 |
+
contentType: false,
|
| 1680 |
+
success: function (res) {
|
| 1681 |
+
$('#files_wccm').show();
|
| 1682 |
+
$(".wccm_results").html("Files uploaded successfully.");
|
| 1683 |
+
|
| 1684 |
+
|
| 1685 |
+
$.ajax({
|
| 1686 |
+
url: '<?php echo admin_url('/post.php?post=' . $post->ID . '&action=edit'); ?>',
|
| 1687 |
+
data: {},
|
| 1688 |
+
success: function (data) {
|
| 1689 |
+
$("div#product_images_container").html($(data).find("div#product_images_container"));
|
| 1690 |
+
$(".wccm_results").html("Files uploaded successfully.");
|
| 1691 |
+
|
| 1692 |
+
},
|
| 1693 |
+
dataType: 'html'
|
| 1694 |
+
});
|
| 1695 |
+
}
|
| 1696 |
+
});
|
| 1697 |
+
}
|
| 1698 |
+
}, false);
|
| 1699 |
+
}
|
| 1700 |
|
| 1701 |
+
());
|
| 1702 |
|
| 1703 |
+
});
|
| 1704 |
</script>
|
| 1705 |
|
| 1706 |
<input type="button" id="wccm_save_order_submit" class="button button-primary" value="<?php _e('Save Changes', 'woocommerce-checkout-manager'); ?>">
|
| 1710 |
</div>
|
| 1711 |
<!-- .woocommerce_order_items_wrapper -->
|
| 1712 |
<?php
|
| 1713 |
+
} */
|
| 1714 |
|
| 1715 |
+
/*
|
| 1716 |
* 1326
|
| 1717 |
* front end for user
|
| 1718 |
+
function wooccm_file_uploader_front_end($order_id) {
|
| 1719 |
|
| 1720 |
global $wpdb, $thepostid, $theorder, $woocommerce, $post;
|
| 1721 |
|
| 1731 |
|
| 1732 |
if (empty($options['checkness']['upload_os']) || ( $order->post_status == $prefix . $options['checkness']['upload_os'] )) {
|
| 1733 |
|
| 1734 |
+
$post_type = 'attachment';
|
| 1735 |
+
$upload_dir = wp_upload_dir();
|
| 1736 |
+
$args = array(
|
| 1737 |
+
'post_type' => $post_type,
|
| 1738 |
+
'numberposts' => -1,
|
| 1739 |
+
'post_status' => null,
|
| 1740 |
+
'post_parent' => $order_id
|
| 1741 |
+
);
|
| 1742 |
+
$default_wccm_values = false;
|
| 1743 |
+
$product_image_gallery = false;
|
| 1744 |
+
$posts = get_posts($args);
|
| 1745 |
+
// wooccm_error_log( 'posts: ' . print_r( $posts, true ) );
|
| 1746 |
+
if (!empty($posts)) {
|
| 1747 |
+
foreach ($posts as $attachment)
|
| 1748 |
+
$array[] = $attachment->ID;
|
| 1749 |
+
$default_wccm_values = implode(',', $array);
|
| 1750 |
+
$product_image_gallery = implode(',', $array);
|
| 1751 |
+
}
|
| 1752 |
+
// wooccm_error_log( 'default_wccm_values: ' . print_r( $default_wccm_values, true ) );
|
| 1753 |
+
// wooccm_error_log( 'product_image_gallery: ' . print_r( $product_image_gallery, true ) );
|
| 1754 |
+
if (!empty($product_image_gallery))
|
| 1755 |
+
$attachments = array_filter(explode(',', $product_image_gallery));
|
| 1756 |
+
// wooccm_error_log( 'attachments: ' . print_r( $attachments, true ) );
|
| 1757 |
+
?>
|
| 1758 |
|
| 1759 |
+
<script type="text/javascript">
|
| 1760 |
+
jQuery(document).ready(function ($) {
|
| 1761 |
+
|
| 1762 |
+
$('#wccm_save_order_submit').click(function () {
|
| 1763 |
+
$(".wccm_results").html("Deleting files, please wait....");
|
| 1764 |
+
var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?>';
|
| 1765 |
+
data = {
|
| 1766 |
+
action: 'update_attachment_wccm',
|
| 1767 |
+
product_image_gallery: $('#product_image_gallery').val(),
|
| 1768 |
+
wccm_default_keys_load: $('#wccm_default_keys_load').val()
|
| 1769 |
+
};
|
| 1770 |
+
|
| 1771 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
| 1772 |
+
$.post(ajaxurl, data, function (response) {
|
| 1773 |
+
$(".wccm_results").html(response);
|
| 1774 |
+
});
|
| 1775 |
+
});
|
| 1776 |
+
|
| 1777 |
+
});
|
| 1778 |
+
</script>
|
| 1779 |
|
| 1780 |
+
<?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/templates/admin/edit-order-uploads-file_editing_table.css', WOOCCM_PLUGIN_FILE)); ?>
|
|
|
|
| 1781 |
|
| 1782 |
+
<h2><?php echo ( empty($options['checkness']['upload_title']) ? 'Order Uploaded Files' : esc_attr($options['checkness']['upload_title']) ); ?></h2>
|
| 1783 |
+
<div class="woocommerce_order_items_wrapper front_end">
|
| 1784 |
+
<table class="shop_table woocommerce_order_items front_end">
|
| 1785 |
+
|
| 1786 |
+
<thead>
|
| 1787 |
+
<tr>
|
| 1788 |
+
<th style="width:15%;text-align: center;"><?php _e('Attachment ID', 'woocommerce-checkout-manager'); ?></th>
|
| 1789 |
+
<th style="width:12%"><?php _e('Image', 'woocommerce-checkout-manager'); ?></th>
|
| 1790 |
+
<th style="width:30%;text-align: center;"><?php _e('Name', 'woocommerce-checkout-manager'); ?></th>
|
| 1791 |
+
<th style="width:12%"><?php _e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
|
| 1792 |
+
<th style="width:8%"><?php _e('Extension', 'woocommerce-checkout-manager'); ?></th>
|
| 1793 |
+
<th style="width:10%" class="column-actions"><?php _e('Actions', 'woocommerce-checkout-manager'); ?></th>
|
| 1794 |
+
</tr>
|
| 1795 |
+
</thead>
|
| 1796 |
+
|
| 1797 |
+
<tbody class="product_images front_end">
|
| 1798 |
+
<?php
|
| 1799 |
+
if (!empty($attachments)) {
|
| 1800 |
+
foreach ($attachments as $attachment_id) {
|
|
|
|
|
|
|
| 1801 |
|
| 1802 |
+
$image_attributes = wp_get_attachment_url($attachment_id);
|
| 1803 |
+
$image_attributes2 = wp_get_attachment_image_src($attachment_id);
|
| 1804 |
+
$filename = basename($image_attributes);
|
| 1805 |
+
$wp_filetype = wp_check_filetype($filename);
|
| 1806 |
|
| 1807 |
+
$value_declear = array_diff(explode(',', $default_wccm_values), explode(',', $attachment_id));
|
| 1808 |
|
| 1809 |
+
echo '
|
| 1810 |
+
<tr class="image wccm_filesli wccmv_' . esc_attr($attachment_id) . '">
|
| 1811 |
|
| 1812 |
+
<td style="display:none;">
|
| 1813 |
+
<script type="text/javascript">
|
| 1814 |
|
| 1815 |
+
jQuery(document).ready(function(){
|
| 1816 |
|
| 1817 |
+
jQuery(".wccmx_' . esc_attr($attachment_id) . '").click(function(){
|
| 1818 |
+
jQuery(".wccmv_' . esc_attr($attachment_id) . '").hide();
|
| 1819 |
+
jQuery("#product_image_gallery").val(jQuery("#product_image_gallery").val().replace("' . esc_attr($attachment_id) . '", ""));
|
| 1820 |
|
| 1821 |
+
});
|
| 1822 |
+
});
|
| 1823 |
|
| 1824 |
+
</script>
|
| 1825 |
+
</td>
|
| 1826 |
+
<td>' . $attachment_id . '</td>
|
| 1827 |
+
<td>' . wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), true)) . '</td>
|
| 1828 |
+
<td>' . wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)) . '</td>
|
| 1829 |
+
<td>';
|
| 1830 |
+
if ($image_attributes2[1] == '') {
|
| 1831 |
+
echo '-';
|
| 1832 |
+
} else {
|
| 1833 |
+
echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
|
| 1834 |
+
}
|
| 1835 |
+
echo '
|
| 1836 |
+
</td>
|
| 1837 |
+
<td>' . strtoupper($wp_filetype['ext']) . '</td>
|
| 1838 |
+
<td class="column-actions" nowrap>
|
| 1839 |
+
<a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . ' button" data-tip="' . __('Delete', 'woocommerce-checkout-manager') . '">' . __('Delete', 'woocommerce-checkout-manager') . '</a>
|
| 1840 |
+
</td>
|
| 1841 |
+
</tr>';
|
| 1842 |
+
}
|
| 1843 |
+
} else {
|
| 1844 |
+
echo '
|
| 1845 |
+
<tr>
|
| 1846 |
+
<td colspan="7">' . __('No uploaded files have been assigned to this Order.', 'woocommerce-checkout-manager') . '</td>
|
| 1847 |
+
</tr>
|
| 1848 |
+
';
|
| 1849 |
+
}
|
| 1850 |
+
?>
|
| 1851 |
+
</tbody>
|
| 1852 |
+
</table>
|
| 1853 |
+
<input type="hidden" class="wccm_add_to_list" id="product_image_gallery" name="product_image_gallery" value="<?php echo (!empty($product_image_gallery) ? esc_attr($product_image_gallery) : '' ); ?>" />
|
| 1854 |
+
<input type="hidden" id="wccm_default_keys_load" name="wccm_default_keys_load" value="<?php echo (!empty($default_wccm_values) ? esc_attr($default_wccm_values) : '' ); ?>" />
|
| 1855 |
+
<!-- .woocommerce_order_items -->
|
| 1856 |
+
</div>
|
| 1857 |
+
<!-- .woocommerce_order_items_wrapper -->
|
| 1858 |
|
| 1859 |
+
<button type="button" id="wccm_save_order_submit" class="file_upload_delete wooccm-btn wooccm-btn-danger delete"><?php _e('Confirm Delete', 'woocommerce-checkout-manager'); ?></button>
|
| 1860 |
|
| 1861 |
+
<span id="wccm_uploader_select">
|
| 1862 |
+
<input type="file" style="display:none;" name="files_wccm" id="files_wccm" multiple />
|
| 1863 |
+
<button type="button" class="file_upload_account wooccm-btn wooccm-btn-primary start" id="files_button_wccm"><?php _e('Upload Files', 'woocommerce-checkout-manager'); ?></button>
|
| 1864 |
+
</span>
|
| 1865 |
+
<!-- #wccm_uploader_select -->
|
| 1866 |
|
| 1867 |
+
<div class="wccm_results front_end"></div>
|
| 1868 |
|
| 1869 |
+
<div class="clear"></div>
|
| 1870 |
+
<?php
|
| 1871 |
+
// script for uploading the files
|
| 1872 |
+
echo '
|
| 1873 |
+
<!-- Edit Order: File upload -->
|
| 1874 |
+
<script type="text/javascript">
|
| 1875 |
+
jQuery(document).ready(function($){
|
| 1876 |
|
| 1877 |
+
(function post_image_content() {
|
| 1878 |
|
| 1879 |
+
var input = document.getElementById("files_wccm"), formdata = false;
|
| 1880 |
|
| 1881 |
+
$("#files_button_wccm").click( function(){
|
| 1882 |
+
$("#wccm_uploader_select input[type=file]").click();
|
| 1883 |
+
return false;
|
| 1884 |
+
});
|
| 1885 |
|
| 1886 |
+
if (window.FormData) {
|
| 1887 |
+
formdata = new FormData();
|
| 1888 |
+
}
|
| 1889 |
|
| 1890 |
+
input.addEventListener("change", function (evt) {
|
| 1891 |
+
$("#wccm_uploader_select").block({
|
| 1892 |
+
message: null,
|
| 1893 |
+
overlayCSS: {
|
| 1894 |
+
background: "#fff",
|
| 1895 |
+
opacity: 0.6
|
| 1896 |
+
}
|
| 1897 |
+
});
|
| 1898 |
|
| 1899 |
+
$("#wccm_uploader_select").block({
|
| 1900 |
+
message: null,
|
| 1901 |
+
overlayCSS: {
|
| 1902 |
+
background: "#fff",
|
| 1903 |
+
opacity: 0.6
|
| 1904 |
+
}
|
| 1905 |
+
});
|
| 1906 |
+
|
| 1907 |
+
var length = ' . $length . ';
|
| 1908 |
+
var file_array = ' . wooccm_js_array($file_types) . ';
|
| 1909 |
+
var wooempt = "' . implode(',', $file_types) . '";
|
| 1910 |
+
|
| 1911 |
+
for ( i = 0; i < length; i++ ) {
|
| 1912 |
+
file = this.files[i];
|
| 1913 |
+
for(x=0; x < ' . $number_of_types . '; x++){
|
| 1914 |
+
if( !wooempt || file.type.match(file_array[x]) ) {
|
| 1915 |
+
if (formdata) {
|
| 1916 |
+
formdata.append("files_wccm[]",file);
|
| 1917 |
+
}
|
| 1918 |
+
}
|
| 1919 |
+
}
|
| 1920 |
+
}
|
| 1921 |
+
|
| 1922 |
+
if (formdata) {
|
| 1923 |
+
$.ajax({
|
| 1924 |
+
url: "' . admin_url('/admin-ajax.php?action=wccs_upload_file_func&order_id=' . $order_id . '&name=files_wccm') . '",
|
| 1925 |
+
type: "POST",
|
| 1926 |
+
data: formdata,
|
| 1927 |
+
processData: false,
|
| 1928 |
+
contentType: false,
|
| 1929 |
+
success: function (res) {
|
| 1930 |
+
$("#files_wccm").show();
|
| 1931 |
+
|
| 1932 |
+
$.ajax({
|
| 1933 |
+
url: "' . $order->get_view_order_url() . '",
|
| 1934 |
+
data: {},
|
| 1935 |
+
success: function (data) {
|
| 1936 |
+
$("div.woocommerce_order_items_wrapper.front_end").html($(data).find("div.woocommerce_order_items_wrapper.front_end"));
|
| 1937 |
+
jQuery("#wccm_uploader_select").unblock();
|
| 1938 |
+
},
|
| 1939 |
+
dataType: "html"
|
| 1940 |
+
});
|
| 1941 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1942 |
}
|
| 1943 |
+
});
|
| 1944 |
+
}
|
| 1945 |
+
}, false);
|
| 1946 |
+
}
|
| 1947 |
+
());
|
| 1948 |
+
});
|
| 1949 |
+
</script>';
|
| 1950 |
+
// end script
|
| 1951 |
+
// ------------
|
| 1952 |
+
}
|
| 1953 |
+
}
|
| 1954 |
+
*/
|
| 1955 |
+
/* function wccs_upload_file_func_callback($order_id) {
|
| 1956 |
|
| 1957 |
$name = ( isset($_REQUEST['name']) ? $_REQUEST['name'] : false );
|
| 1958 |
$order_id = ( isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : false );
|
| 1959 |
|
| 1960 |
if (empty($name)) {
|
| 1961 |
+
echo ' ' . __('Upload failed. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
|
| 1962 |
+
die();
|
| 1963 |
}
|
| 1964 |
|
| 1965 |
if (empty($order_id)) {
|
| 1966 |
+
echo ' ' . __('Invalid Order. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
|
| 1967 |
+
die();
|
| 1968 |
}
|
| 1969 |
|
| 1970 |
global $wpdb, $woocommerce, $post; // this is how you get access to the database
|
| 1984 |
// $upload_overrides = array( 'test_form' => false );
|
| 1985 |
|
| 1986 |
if (!empty($files['name'])) {
|
| 1987 |
+
foreach ($files['name'] as $key => $value) {
|
| 1988 |
+
if ($files['name'][$key]) {
|
| 1989 |
+
|
| 1990 |
+
$file = array(
|
| 1991 |
+
'name' => $files['name'][$key],
|
| 1992 |
+
'type' => $files['type'][$key],
|
| 1993 |
+
'tmp_name' => $files['tmp_name'][$key],
|
| 1994 |
+
'error' => $files['error'][$key],
|
| 1995 |
+
'size' => $files['size'][$key]
|
| 1996 |
+
);
|
| 1997 |
|
| 1998 |
+
if (!empty($options['checkness']['cat_file_upload'])) {
|
| 1999 |
+
add_filter('upload_dir', function( $param ) use ( $order_id ) {
|
| 2000 |
+
$param['path'] = sprintf('%s/wooccm_uploads/%d', $param['basedir'], $order_id);
|
| 2001 |
+
$param['url'] = sprintf('%s/wooccm_uploads/%d', $param['baseurl'], $order_id);
|
| 2002 |
+
return $param;
|
| 2003 |
+
}, 10, 1);
|
| 2004 |
+
}
|
| 2005 |
|
| 2006 |
+
// $movefile = wp_handle_upload($file, $upload_overrides);
|
| 2007 |
+
$movefile = wp_handle_upload($file);
|
| 2008 |
|
| 2009 |
+
// Check if the save process failed
|
| 2010 |
+
if (isset($movefile['error'])) {
|
| 2011 |
+
echo 'Could not save uploaded file. Files were not uploaded.';
|
| 2012 |
+
die();
|
| 2013 |
+
}
|
| 2014 |
|
| 2015 |
+
$attachment = array(
|
| 2016 |
+
'guid' => $movefile['url'],
|
| 2017 |
+
'post_mime_type' => $movefile['type'],
|
| 2018 |
+
'post_title' => preg_replace('/\.[^.]+$/', '', basename($movefile['file'])),
|
| 2019 |
+
'post_content' => '',
|
| 2020 |
+
'post_status' => 'inherit',
|
| 2021 |
+
'post_parent' => $order_id
|
| 2022 |
+
);
|
| 2023 |
|
| 2024 |
+
$attach_id = wp_insert_attachment($attachment, $movefile['url'], $order_id);
|
| 2025 |
|
| 2026 |
+
// you must first include the image.php file
|
| 2027 |
+
// for the function wp_generate_attachment_metadata() to work
|
| 2028 |
|
| 2029 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
| 2030 |
+
$attach_data = wp_generate_attachment_metadata($attach_id, $movefile['url']);
|
| 2031 |
+
wp_update_attachment_metadata($attach_id, $attach_data);
|
| 2032 |
|
| 2033 |
+
$has_uploads = true;
|
| 2034 |
+
}
|
| 2035 |
+
}
|
| 2036 |
+
if ($has_uploads) {
|
| 2037 |
|
| 2038 |
+
// send email
|
| 2039 |
+
$email_recipients = $options['checkness']['wooccm_notification_email'];
|
| 2040 |
+
if (empty($email_recipients))
|
| 2041 |
+
$email_recipients = get_option('admin_email');
|
| 2042 |
+
$email_heading = __('Files Uploaded by Customer', 'woocommerce-checkout-manager');
|
| 2043 |
+
$subject = sprintf(__('WooCommerce Checkout Manager - %s [%s]', 'woocommerce-checkout-manager'), $email_heading, $order->billing_first_name . ' ' . $order->billing_last_name);
|
| 2044 |
|
| 2045 |
+
$mailer = WC()->mailer();
|
| 2046 |
|
| 2047 |
+
// Buffer
|
| 2048 |
+
ob_start();
|
| 2049 |
+
?>
|
| 2050 |
+
<p>This is an automatic message from WooCommerce Checkout Manager, reporting that files have been uploaded by <?php echo $order->billing_first_name; ?> <?php echo $order->billing_last_name; ?>.</p>
|
| 2051 |
+
<h3>Customer Details</h3>
|
| 2052 |
+
<ul>
|
| 2053 |
+
<li>Name: <?php echo $order->billing_first_name; ?> <?php $order->billing_last_name; ?></li>
|
| 2054 |
+
<li>E-mail: <?php echo $order->billing_email; ?></li>
|
| 2055 |
+
<li>Order Number: <?php echo $order_id; ?></li>
|
| 2056 |
+
</ul>
|
| 2057 |
+
<p>You can view the files and order details via back-end by following this <a href="<?php echo admin_url('/post.php?post=' . $order_id . '&action=edit'); ?>" target="_blank">link</a>.</p>
|
| 2058 |
+
<?php
|
| 2059 |
+
// Get contents
|
| 2060 |
+
$message = ob_get_clean();
|
| 2061 |
|
| 2062 |
+
$message = $mailer->wrap_message($email_heading, $message);
|
| 2063 |
|
| 2064 |
+
// add_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
|
| 2065 |
+
// wc_mail( $email_recipients, $subject, $message );
|
| 2066 |
+
$mailer->send($email_recipients, strip_tags($subject), $message);
|
| 2067 |
+
// remove_filter( 'wp_mail_content_type', 'wooccm_set_html_content_type' );
|
| 2068 |
+
}
|
| 2069 |
+
echo ' ' . __('Files were uploaded successfully.', 'woocommerce-checkout-manager') . '';
|
| 2070 |
} else {
|
| 2071 |
+
echo ' ' . __('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager') . '';
|
| 2072 |
}
|
| 2073 |
die();
|
| 2074 |
+
} */
|
| 2075 |
|
| 2076 |
//1326
|
| 2077 |
//add_action("wp_ajax_wccs_upload_file_func", "wccs_upload_file_func_callback");
|
| 2081 |
* function wooccm_set_html_content_type() {
|
| 2082 |
|
| 2083 |
return 'text/html';
|
| 2084 |
+
} */
|
| 2085 |
|
| 2086 |
function wooccm_js_str($s) {
|
| 2087 |
|
includes/install.php
CHANGED
|
@@ -1,250 +1,251 @@
|
|
| 1 |
<?php
|
|
|
|
| 2 |
// Plugin activation script
|
| 3 |
function wooccm_install() {
|
| 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 |
?>
|
| 1 |
<?php
|
| 2 |
+
|
| 3 |
// Plugin activation script
|
| 4 |
function wooccm_install() {
|
| 5 |
|
| 6 |
+
$options = get_option('wccs_settings');
|
| 7 |
+
$options2 = get_option('wccs_settings2');
|
| 8 |
+
$options3 = get_option('wccs_settings3');
|
| 9 |
+
|
| 10 |
+
update_option(WOOCCM_PREFIX . '_update_notice', 0);
|
| 11 |
+
|
| 12 |
+
if (function_exists('icl_register_string'))
|
| 13 |
+
icl_register_string('WooCommerce Checkout Manager', 'is a required field.', 'is a required field.');
|
| 14 |
+
|
| 15 |
+
if (empty($options['checkness']['position'])) {
|
| 16 |
+
$options['checkness']['position'] = 'after_order_notes';
|
| 17 |
+
}
|
| 18 |
+
if (empty($options['checkness']['wooccm_notification_email'])) {
|
| 19 |
+
$options['checkness']['wooccm_notification_email'] = get_option('admin_email');
|
| 20 |
+
}
|
| 21 |
+
if (empty($options['checkness']['payment_method_d'])) {
|
| 22 |
+
$options['checkness']['payment_method_d'] = 'Payment Method';
|
| 23 |
+
}
|
| 24 |
+
if (empty($options['checkness']['time_stamp_title'])) {
|
| 25 |
+
$options['checkness']['time_stamp_title'] = 'Order Time';
|
| 26 |
+
}
|
| 27 |
+
if (empty($options['checkness']['payment_method_t'])) {
|
| 28 |
+
$options['checkness']['payment_method_t'] = '1';
|
| 29 |
+
}
|
| 30 |
+
if (empty($options['checkness']['shipping_method_d'])) {
|
| 31 |
+
$options['checkness']['shipping_method_d'] = 'Shipping Method';
|
| 32 |
+
}
|
| 33 |
+
if (empty($options['checkness']['shipping_method_t'])) {
|
| 34 |
+
$options['checkness']['shipping_method_t'] = '1';
|
| 35 |
+
}
|
| 36 |
+
if (empty($options2['shipping_buttons'])) {
|
| 37 |
+
$shipping = array(
|
| 38 |
+
'country' => 'Country',
|
| 39 |
+
'first_name' => 'First Name',
|
| 40 |
+
'last_name' => 'Last Name',
|
| 41 |
+
'company' => 'Company Name',
|
| 42 |
+
'address_1' => 'Address',
|
| 43 |
+
'address_2' => '',
|
| 44 |
+
'city' => 'Town/ City',
|
| 45 |
+
'state' => 'State',
|
| 46 |
+
'postcode' => 'Zip'
|
| 47 |
+
);
|
| 48 |
+
$ship = 0;
|
| 49 |
+
foreach ($shipping as $name => $value) {
|
| 50 |
+
|
| 51 |
+
$options2['shipping_buttons'][$ship]['label'] = (!empty($value) ? __($value, 'woocommerce-checkout-manager') : false );
|
| 52 |
+
$options2['shipping_buttons'][$ship]['cow'] = $name;
|
| 53 |
+
$options2['shipping_buttons'][$ship]['checkbox'] = 'true';
|
| 54 |
+
$options2['shipping_buttons'][$ship]['order'] = $ship + 1;
|
| 55 |
+
$options2['shipping_buttons'][$ship]['type'] = 'wooccmtext';
|
| 56 |
+
|
| 57 |
+
if ($name == 'country') {
|
| 58 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if ($name == 'first_name') {
|
| 62 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-first';
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if ($name == 'last_name') {
|
| 66 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-last';
|
| 67 |
+
$options2['shipping_buttons'][$ship]['clear_row'] = true;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if ($name == 'company') {
|
| 71 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
if ($name == 'address_1') {
|
| 75 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 76 |
+
$options2['shipping_buttons'][$ship]['placeholder'] = __('Street address', 'woocommerce-checkout-manager');
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if ($name == 'address_2') {
|
| 80 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 81 |
+
$options2['shipping_buttons'][$ship]['placeholder'] = __('Apartment, suite, unit etc. (optional)', 'woocommerce-checkout-manager');
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if ($name == 'city') {
|
| 85 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 86 |
+
$options2['shipping_buttons'][$ship]['placeholder'] = __('Town / City', 'woocommerce-checkout-manager');
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
if ($name == 'state') {
|
| 90 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if ($name == 'postcode') {
|
| 94 |
+
$options2['shipping_buttons'][$ship]['position'] = 'form-row-wide';
|
| 95 |
+
$options2['shipping_buttons'][$ship]['placeholder'] = __('Postcode / Zip', 'woocommerce-checkout-manager');
|
| 96 |
+
$options2['shipping_buttons'][$ship]['clear_row'] = true;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
$ship++;
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
if (empty($options3['billing_buttons'])) {
|
| 104 |
+
$billing = array(
|
| 105 |
+
'country' => 'Country',
|
| 106 |
+
'first_name' => 'First Name',
|
| 107 |
+
'last_name' => 'Last Name',
|
| 108 |
+
'company' => 'Company Name',
|
| 109 |
+
'address_1' => 'Address',
|
| 110 |
+
'address_2' => '',
|
| 111 |
+
'city' => 'Town/ City',
|
| 112 |
+
'state' => 'State',
|
| 113 |
+
'postcode' => 'Zip',
|
| 114 |
+
'email' => 'Email Address',
|
| 115 |
+
'phone' => 'Phone'
|
| 116 |
+
);
|
| 117 |
+
$bill = 0;
|
| 118 |
+
foreach ($billing as $name => $value) {
|
| 119 |
+
|
| 120 |
+
$options3['billing_buttons'][$bill]['label'] = (!empty($value) ? __($value, 'woocommerce-checkout-manager') : false );
|
| 121 |
+
$options3['billing_buttons'][$bill]['cow'] = $name;
|
| 122 |
+
$options3['billing_buttons'][$bill]['checkbox'] = 'true';
|
| 123 |
+
$options3['billing_buttons'][$bill]['order'] = $bill + 1;
|
| 124 |
+
$options3['billing_buttons'][$bill]['type'] = 'wooccmtext';
|
| 125 |
+
|
| 126 |
+
if ($name == 'country') {
|
| 127 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 128 |
+
$options3['billing_buttons'][$bill]['type'] = 'wooccmcountry';
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
if ($name == 'first_name') {
|
| 132 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-first';
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
if ($name == 'last_name') {
|
| 136 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-last';
|
| 137 |
+
$options3['billing_buttons'][$bill]['clear_row'] = true;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
if ($name == 'company') {
|
| 141 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if ($name == 'address_1') {
|
| 145 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 146 |
+
$options3['billing_buttons'][$bill]['placeholder'] = __('Street address', 'woocommerce-checkout-manager');
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
if ($name == 'address_2') {
|
| 150 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 151 |
+
$options3['billing_buttons'][$bill]['placeholder'] = __('Apartment, suite, unit etc. (optional)', 'woocommerce-checkout-manager');
|
| 152 |
+
$options3['billing_buttons'][$bill]['required'] = false;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
if ($name == 'city') {
|
| 156 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 157 |
+
$options3['billing_buttons'][$bill]['placeholder'] = __('Town / City', 'woocommerce-checkout-manager');
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
if ($name == 'state') {
|
| 161 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 162 |
+
$options3['billing_buttons'][$bill]['type'] = 'wooccmstate';
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
if ($name == 'postcode') {
|
| 166 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-wide';
|
| 167 |
+
$options3['billing_buttons'][$bill]['placeholder'] = __('Postcode / Zip', 'woocommerce-checkout-manager');
|
| 168 |
+
$options3['billing_buttons'][$bill]['clear_row'] = true;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
if ($name == 'email') {
|
| 172 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-first';
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
if ($name == 'phone') {
|
| 176 |
+
$options3['billing_buttons'][$bill]['position'] = 'form-row-last';
|
| 177 |
+
$options3['billing_buttons'][$bill]['clear_row'] = true;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
$bill++;
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
if (!empty($options['buttons'])) {
|
| 185 |
+
foreach ($options['buttons'] as $i => $btn) {
|
| 186 |
+
|
| 187 |
+
if (!empty($btn['check_1']) || !empty($btn['check_2'])) {
|
| 188 |
+
$options['buttons'][$i]['option_array'] = implode('||', array(wooccm_wpml_string($btn['check_1']), wooccm_wpml_string($btn['check_2'])));
|
| 189 |
+
$options['buttons'][$i]['check_1'] = '';
|
| 190 |
+
$options['buttons'][$i]['check_2'] = '';
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
$options['buttons'][$i]['type'] = ( $btn['type'] == 'checkbox' ) ? 'checkbox_wccm' : $btn['type'];
|
| 194 |
+
$options['buttons'][$i]['type'] = ( $btn['type'] == 'text' ) ? 'wooccmtext' : $btn['type'];
|
| 195 |
+
$options['buttons'][$i]['type'] = ( $btn['type'] == 'select' ) ? 'wooccmselect' : $btn['type'];
|
| 196 |
+
$options['buttons'][$i]['type'] = ( $btn['type'] == 'date' ) ? 'datepicker' : $btn['type'];
|
| 197 |
+
|
| 198 |
+
if (empty($btn['option_array'])) {
|
| 199 |
+
$btn['option_array'] = '';
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
$mysecureop = explode('||', $btn['option_array']);
|
| 203 |
+
|
| 204 |
+
if (!empty($btn['option_a'])) {
|
| 205 |
+
array_push($mysecureop, $btn['option_a']);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
if (!empty($btn['option_b'])) {
|
| 209 |
+
array_push($mysecureop, $btn['option_b']);
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
$uniqueThevalues = array_unique($mysecureop);
|
| 213 |
+
|
| 214 |
+
$options['buttons'][$i]['option_array'] = implode('||', $uniqueThevalues);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
foreach ($options3['billing_buttons'] as $i => $btn) {
|
| 219 |
+
|
| 220 |
+
if (!empty($btn['check_1']) || !empty($btn['check_2'])) {
|
| 221 |
+
$options3['billing_buttons'][$i]['option_array'] = implode('||', array(wooccm_wpml_string($btn['check_1']), wooccm_wpml_string($btn['check_2'])));
|
| 222 |
+
$options3['billing_buttons'][$i]['check_1'] = '';
|
| 223 |
+
$options3['billing_buttons'][$i]['check_2'] = '';
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
$options3['billing_buttons'][$i]['type'] = ( $btn['type'] == 'checkbox' ) ? 'checkbox_wccm' : $btn['type'];
|
| 227 |
+
$options3['billing_buttons'][$i]['type'] = ( $btn['type'] == 'text' ) ? 'wooccmtext' : $btn['type'];
|
| 228 |
+
$options3['billing_buttons'][$i]['type'] = ( $btn['type'] == 'select' ) ? 'wooccmselect' : $btn['type'];
|
| 229 |
+
$options3['billing_buttons'][$i]['type'] = ( $btn['type'] == 'date' ) ? 'datepicker' : $btn['type'];
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
foreach ($options2['shipping_buttons'] as $i => $btn) {
|
| 233 |
+
|
| 234 |
+
if (!empty($btn['check_1']) || !empty($btn['check_2'])) {
|
| 235 |
+
$options2['shipping_buttons'][$i]['option_array'] = implode('||', array(wooccm_wpml_string($btn['check_1']), wooccm_wpml_string($btn['check_2'])));
|
| 236 |
+
$options2['shipping_buttons'][$i]['check_1'] = '';
|
| 237 |
+
$options2['shipping_buttons'][$i]['check_2'] = '';
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
$options2['shipping_buttons'][$i]['type'] = ( $btn['type'] == 'checkbox' ) ? 'checkbox_wccm' : $btn['type'];
|
| 241 |
+
$options2['shipping_buttons'][$i]['type'] = ( $btn['type'] == 'text' ) ? 'wooccmtext' : $btn['type'];
|
| 242 |
+
$options2['shipping_buttons'][$i]['type'] = ( $btn['type'] == 'select' ) ? 'wooccmselect' : $btn['type'];
|
| 243 |
+
$options2['shipping_buttons'][$i]['type'] = ( $btn['type'] == 'date' ) ? 'datepicker' : $btn['type'];
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
update_option('wccs_settings', $options);
|
| 247 |
+
update_option('wccs_settings2', $options2);
|
| 248 |
+
update_option('wccs_settings3', $options3);
|
|
|
|
| 249 |
}
|
| 250 |
+
|
| 251 |
?>
|
new/fields_handler.php
CHANGED
|
@@ -7,7 +7,7 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
|
|
| 7 |
protected static $instance;
|
| 8 |
protected static $i = 0;
|
| 9 |
|
| 10 |
-
function field_user_roles($field, $key, $args, $value) {
|
| 11 |
|
| 12 |
global $current_user;
|
| 13 |
|
|
@@ -31,34 +31,61 @@ if (!class_exists('WOOCCM_Fields_Handler')) {
|
|
| 31 |
}
|
| 32 |
|
| 33 |
return $field;
|
| 34 |
-
}
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
$
|
| 40 |
-
}
|
| 41 |
-
//error_log($field);
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
function init() {
|
| 59 |
-
|
| 60 |
-
//
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
|
| 64 |
public static function instance() {
|
| 7 |
protected static $instance;
|
| 8 |
protected static $i = 0;
|
| 9 |
|
| 10 |
+
/*function field_user_roles($field, $key, $args, $value) {
|
| 11 |
|
| 12 |
global $current_user;
|
| 13 |
|
| 31 |
}
|
| 32 |
|
| 33 |
return $field;
|
| 34 |
+
}*/
|
| 35 |
|
| 36 |
+
function remove_checkout_fields($fields) {
|
| 37 |
|
| 38 |
+
foreach ($fields as $key => $type) {
|
| 39 |
+
foreach ($type as $id => $field) {
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
// Remove disabled
|
| 42 |
+
// -------------------------------------------------------------------
|
| 43 |
+
if (!empty($field['disabled'])) {
|
| 44 |
+
unset($fields[$key][$id]);
|
| 45 |
+
}
|
| 46 |
+
// Remove based on roles
|
| 47 |
+
// -------------------------------------------------------------------
|
| 48 |
+
|
| 49 |
+
if (!empty($field['user_role']) && (!empty($field['role_options']) || !empty($field['role_options2']))) {
|
| 50 |
|
| 51 |
+
$rolekeys = explode('||', $field['role_options']);
|
| 52 |
|
| 53 |
+
$rolekeys2 = explode('||', $field['role_options2']);
|
| 54 |
|
| 55 |
+
if (!empty($field['role_options']) && !in_array($user_role, $rolekeys)) {
|
| 56 |
+
unset($fields[$key][$id]);
|
| 57 |
+
}
|
| 58 |
|
| 59 |
+
if (!empty($field['role_options2']) && in_array($user_role, $rolekeys2)) {
|
| 60 |
+
unset($fields[$key][$id]);
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
// Fix for required address field
|
| 67 |
+
if (get_option('woocommerce_ship_to_destination') == 'billing_only') {
|
| 68 |
+
unset($fields['shipping']);
|
| 69 |
}
|
| 70 |
|
| 71 |
+
return $fields;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function woocommerce_checkout_address_2_field($option) {
|
| 75 |
+
return 'required';
|
| 76 |
}
|
| 77 |
|
| 78 |
function init() {
|
| 79 |
+
|
| 80 |
+
// Remove fields
|
| 81 |
+
// -----------------------------------------------------------------------
|
| 82 |
+
add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
|
| 83 |
+
|
| 84 |
+
// Fix address_2 field
|
| 85 |
+
// -----------------------------------------------------------------------
|
| 86 |
+
add_filter('default_option_woocommerce_checkout_address_2_field', array($this, 'woocommerce_checkout_address_2_field'));
|
| 87 |
+
|
| 88 |
+
//add_filter('woocommerce_form_field', array($this, 'field_user_roles'), 10, 4);
|
| 89 |
}
|
| 90 |
|
| 91 |
public static function instance() {
|
new/fields_register.php
CHANGED
|
@@ -32,71 +32,116 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 32 |
'country'
|
| 33 |
);
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
$fields[$key]['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
} else {
|
| 42 |
-
$fields[$key]['
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
|
|
|
|
|
|
| 45 |
if ($custom_field['cow'] !== 'country' || $custom_field['cow'] !== 'state') {
|
| 46 |
$fields[$key]['placeholder'] = ( isset($custom_field['placeholder']) ? $custom_field['placeholder'] : '' );
|
| 47 |
}
|
| 48 |
-
|
| 49 |
-
//
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
$fields[$key]['
|
| 54 |
-
|
| 55 |
-
$fields[$key]['options'] = ( isset($custom_field['option_array']) ? $custom_field['option_array'] : '' );
|
| 56 |
-
$fields[$key]['user_role'] = ( isset($custom_field['user_role']) ? $custom_field['user_role'] : '' );
|
| 57 |
-
$fields[$key]['role_options'] = ( isset($custom_field['role_options']) ? $custom_field['role_options'] : '' );
|
| 58 |
-
$fields[$key]['role_options2'] = ( isset($custom_field['role_options2']) ? $custom_field['role_options2'] : '' );
|
| 59 |
-
//$fields[$key]['required'] = ( isset($custom_field['checkbox']) ? $custom_field['checkbox'] : '' );
|
| 60 |
-
$fields[$key]['wooccm_required'] = ( isset($custom_field['checkbox']) ? $custom_field['checkbox'] : '' );
|
| 61 |
-
$fields[$key]['cow'] = ( isset($custom_field['cow']) ? $custom_field['cow'] : '' );
|
| 62 |
-
$fields[$key]['color'] = ( isset($custom_field['colorpickerd']) ? $custom_field['colorpickerd'] : '' );
|
| 63 |
-
$fields[$key]['colorpickertype'] = ( isset($custom_field['colorpickertype']) ? $custom_field['colorpickertype'] : '' );
|
| 64 |
-
$fields[$key]['order'] = ( isset($custom_field['order']) ? $custom_field['order'] : '' );
|
| 65 |
-
$fields[$key]['priority'] = ( isset($custom_field['priority']) ? $custom_field['priority'] : $fields[$key]['order'] );
|
| 66 |
-
$fields[$key]['fancy'] = ( isset($custom_field['fancy']) ? $custom_field['fancy'] : '' );
|
| 67 |
-
|
| 68 |
-
// 1326
|
| 69 |
-
// -----------------------------------------------------------------------
|
| 70 |
-
//if ($custom_field['type'] == 'wooccmtext' || $fields[$key]['type'] == 'wooccmtext') {
|
| 71 |
-
//$fields[$key]['type'] = 'text';
|
| 72 |
-
//}
|
| 73 |
-
|
| 74 |
-
if ($custom_field['type'] == 'wooccmstate' || $fields[$key]['type'] == 'wooccmstate') {
|
| 75 |
-
$fields[$key]['type'] = 'state';
|
| 76 |
}
|
| 77 |
|
| 78 |
-
if ($
|
|
|
|
|
|
|
|
|
|
| 79 |
$fields[$key]['type'] = 'country';
|
| 80 |
}
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
// Remove required for heading
|
|
|
|
| 83 |
if ($custom_field['type'] == 'heading') {
|
| 84 |
$fields[$key]['required'] = false;
|
| 85 |
-
|
| 86 |
-
//error_log(json_encode($fields[$key]));
|
| 87 |
}
|
| 88 |
|
| 89 |
// Check if Multi-checkbox has options assigned to it
|
|
|
|
| 90 |
if ($custom_field['type'] == 'multicheckbox' && empty($custom_field['option_array'])) {
|
| 91 |
$custom_field['disabled'] = true;
|
| 92 |
}
|
| 93 |
|
| 94 |
// Bolt on address-field for address-based fields
|
|
|
|
| 95 |
if (in_array($custom_field['cow'], $defaults)) {
|
| 96 |
$fields[$key]['class'][] = 'address-field';
|
| 97 |
}
|
| 98 |
|
| 99 |
// Override for State fields
|
|
|
|
| 100 |
if ($fields[$key]['type'] == 'wooccmstate') {
|
| 101 |
$country_key = false;
|
| 102 |
if ($key == 'billing_state') {
|
|
@@ -132,18 +177,18 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 132 |
|
| 133 |
$key = sprintf("%s%s", $prefix, $custom_field['cow']);
|
| 134 |
|
| 135 |
-
$fields[$key] = $this->add_checkout_field_filter($key, $fields, $custom_field);
|
| 136 |
-
|
| 137 |
// Remove disabled fields
|
| 138 |
-
if (!empty($custom_field['disabled'])) {
|
| 139 |
-
|
| 140 |
-
}
|
|
|
|
|
|
|
| 141 |
}
|
| 142 |
}
|
| 143 |
}
|
| 144 |
}
|
| 145 |
|
| 146 |
-
|
| 147 |
$fields[] = uasort($fields, 'wooccm_sort_fields');
|
| 148 |
|
| 149 |
if ($fields[0]) {
|
|
@@ -175,22 +220,19 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 175 |
}
|
| 176 |
|
| 177 |
function add_checkout_billing_fields($fields) {
|
| 178 |
-
|
| 179 |
-
//error_log('add_checkout_billing_fields');
|
| 180 |
-
|
| 181 |
return $this->add_checkout_fields_filter($fields, 'wccs_settings3', 'billing_buttons', 'billing_');
|
| 182 |
}
|
| 183 |
|
| 184 |
function init() {
|
| 185 |
-
|
| 186 |
// Billing fields
|
| 187 |
// -----------------------------------------------------------------------
|
| 188 |
add_filter('woocommerce_billing_fields', array($this, 'add_checkout_billing_fields'));
|
| 189 |
-
|
| 190 |
// Shipping fields
|
| 191 |
// -----------------------------------------------------------------------
|
| 192 |
-
|
| 193 |
add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
|
|
|
|
| 194 |
// Additional fields
|
| 195 |
// -----------------------------------------------------------------------
|
| 196 |
switch ($this->get_positioning()) {
|
|
@@ -214,12 +256,6 @@ if (!class_exists('WOOCCM_Fields_Register')) {
|
|
| 214 |
add_action('woocommerce_after_order_notes', array($this, 'add_checkout_additional_fields'));
|
| 215 |
break;
|
| 216 |
}
|
| 217 |
-
|
| 218 |
-
// Default pptions
|
| 219 |
-
// -----------------------------------------------------------------------
|
| 220 |
-
//add_filter('default_option_wccs_settings', array($this, 'wccs_settings'));
|
| 221 |
-
//add_filter('default_option_wccs_settings2', array($this, 'wccs_settings2'));
|
| 222 |
-
//add_filter('default_option_wccs_settings3', array($this, 'wccs_settings3'));
|
| 223 |
}
|
| 224 |
|
| 225 |
public static function instance() {
|
| 32 |
'country'
|
| 33 |
);
|
| 34 |
|
| 35 |
+
$fields[$key] = wp_parse_args($custom_field, (array) @$fields[$key]);
|
| 36 |
+
|
| 37 |
+
// Priority
|
| 38 |
+
// -----------------------------------------------------------------------
|
| 39 |
+
if (isset($custom_field['order'])) {
|
| 40 |
+
$fields[$key]['priority'] = $fields[$key]['order'];
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// Color
|
| 44 |
+
// -----------------------------------------------------------------------
|
| 45 |
+
if (isset($custom_field['colorpickerd'])) {
|
| 46 |
+
$fields[$key]['color'] = $fields[$key]['colorpickerd'];
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
// Options
|
| 50 |
+
// -----------------------------------------------------------------------
|
| 51 |
+
if (isset($custom_field['force_title2'])) {
|
| 52 |
+
$fields[$key]['option'] = $fields[$key]['force_title2'];
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// Default
|
| 56 |
+
// -----------------------------------------------------------------------
|
| 57 |
+
if (isset($custom_field['force_title2'])) {
|
| 58 |
+
$fields[$key]['default'] = $fields[$key]['force_title2'];
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
// Clear
|
| 62 |
+
// -----------------------------------------------------------------------
|
| 63 |
+
//var_dump($fields[$key]);
|
| 64 |
+
|
| 65 |
+
if (isset($custom_field['clear_row'])) {
|
| 66 |
+
$fields[$key]['clear'] = $fields[$key]['clear_row'];
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// Class
|
| 70 |
+
// -----------------------------------------------------------------------
|
| 71 |
+
|
| 72 |
+
if (isset($fields[$key]['class'])) {
|
| 73 |
+
if (isset($custom_field['position'])) {
|
| 74 |
+
$fields[$key]['class'] = array_diff($fields[$key]['class'], array('form-row-wide', 'form-row-first', 'form-row-last'));
|
| 75 |
+
$fields[$key]['class'][] = $custom_field['position'];
|
| 76 |
+
}
|
| 77 |
+
if (isset($custom_field['conditional_tie'])) {
|
| 78 |
+
$fields[$key]['class'][] = $custom_field['conditional_tie'];
|
| 79 |
+
}
|
| 80 |
+
if (isset($custom_field['extra_class'])) {
|
| 81 |
+
$fields[$key]['class'][] = $custom_field['extra_class'];
|
| 82 |
+
}
|
| 83 |
} else {
|
| 84 |
+
$fields[$key]['class'] = array('form-row-wide');
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
if (!empty($custom_field['clear_row'])) {
|
| 88 |
+
$fields[$key]['class'][] = 'wooccm-clearfix';
|
| 89 |
}
|
| 90 |
|
| 91 |
+
// Remove placeholder
|
| 92 |
+
// -----------------------------------------------------------------------
|
| 93 |
if ($custom_field['cow'] !== 'country' || $custom_field['cow'] !== 'state') {
|
| 94 |
$fields[$key]['placeholder'] = ( isset($custom_field['placeholder']) ? $custom_field['placeholder'] : '' );
|
| 95 |
}
|
| 96 |
+
|
| 97 |
+
//var_dump($fields[$key]);
|
| 98 |
+
|
| 99 |
+
// Scape wooccm field fielter
|
| 100 |
+
// -----------------------------------------------------------------------
|
| 101 |
+
if ($fields[$key]['type'] == 'wooccmtext') {
|
| 102 |
+
$fields[$key]['type'] = 'text';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
+
if ($fields[$key]['type'] == 'wooccmstate') {
|
| 106 |
+
$fields[$key]['type'] = 'state';
|
| 107 |
+
}
|
| 108 |
+
if ($fields[$key]['type'] == 'wooccmcountry') {
|
| 109 |
$fields[$key]['type'] = 'country';
|
| 110 |
}
|
| 111 |
|
| 112 |
+
// Required
|
| 113 |
+
// -----------------------------------------------------------------------
|
| 114 |
+
if (!empty($custom_field['checkbox'])) {
|
| 115 |
+
$fields[$key]['checkbox'] = true;
|
| 116 |
+
$fields[$key]['required'] = true;
|
| 117 |
+
$fields[$key]['wooccm_required'] = true;
|
| 118 |
+
} else {
|
| 119 |
+
$fields[$key]['checkbox'] = false;
|
| 120 |
+
$fields[$key]['required'] = false;
|
| 121 |
+
$fields[$key]['wooccm_required'] = false;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
//echo ($key . '//' . intval($fields[$key]['required']));
|
| 125 |
// Remove required for heading
|
| 126 |
+
// -----------------------------------------------------------------------
|
| 127 |
if ($custom_field['type'] == 'heading') {
|
| 128 |
$fields[$key]['required'] = false;
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
|
| 131 |
// Check if Multi-checkbox has options assigned to it
|
| 132 |
+
// -----------------------------------------------------------------------
|
| 133 |
if ($custom_field['type'] == 'multicheckbox' && empty($custom_field['option_array'])) {
|
| 134 |
$custom_field['disabled'] = true;
|
| 135 |
}
|
| 136 |
|
| 137 |
// Bolt on address-field for address-based fields
|
| 138 |
+
// -----------------------------------------------------------------------
|
| 139 |
if (in_array($custom_field['cow'], $defaults)) {
|
| 140 |
$fields[$key]['class'][] = 'address-field';
|
| 141 |
}
|
| 142 |
|
| 143 |
// Override for State fields
|
| 144 |
+
// -----------------------------------------------------------------------
|
| 145 |
if ($fields[$key]['type'] == 'wooccmstate') {
|
| 146 |
$country_key = false;
|
| 147 |
if ($key == 'billing_state') {
|
| 177 |
|
| 178 |
$key = sprintf("%s%s", $prefix, $custom_field['cow']);
|
| 179 |
|
|
|
|
|
|
|
| 180 |
// Remove disabled fields
|
| 181 |
+
//if (!empty($custom_field['disabled'])) {
|
| 182 |
+
//unset($fields[$key]);
|
| 183 |
+
//} else {
|
| 184 |
+
$fields[$key] = $this->add_checkout_field_filter($key, $fields, $custom_field);
|
| 185 |
+
//}
|
| 186 |
}
|
| 187 |
}
|
| 188 |
}
|
| 189 |
}
|
| 190 |
|
| 191 |
+
// Resort the fields by order
|
| 192 |
$fields[] = uasort($fields, 'wooccm_sort_fields');
|
| 193 |
|
| 194 |
if ($fields[0]) {
|
| 220 |
}
|
| 221 |
|
| 222 |
function add_checkout_billing_fields($fields) {
|
|
|
|
|
|
|
|
|
|
| 223 |
return $this->add_checkout_fields_filter($fields, 'wccs_settings3', 'billing_buttons', 'billing_');
|
| 224 |
}
|
| 225 |
|
| 226 |
function init() {
|
| 227 |
+
|
| 228 |
// Billing fields
|
| 229 |
// -----------------------------------------------------------------------
|
| 230 |
add_filter('woocommerce_billing_fields', array($this, 'add_checkout_billing_fields'));
|
| 231 |
+
|
| 232 |
// Shipping fields
|
| 233 |
// -----------------------------------------------------------------------
|
|
|
|
| 234 |
add_filter('woocommerce_shipping_fields', array($this, 'add_checkout_shipping_fields'));
|
| 235 |
+
|
| 236 |
// Additional fields
|
| 237 |
// -----------------------------------------------------------------------
|
| 238 |
switch ($this->get_positioning()) {
|
| 256 |
add_action('woocommerce_after_order_notes', array($this, 'add_checkout_additional_fields'));
|
| 257 |
break;
|
| 258 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
}
|
| 260 |
|
| 261 |
public static function instance() {
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/
|
|
| 4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 5.2.3
|
| 7 |
-
Stable tag: 4.3.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -137,6 +137,10 @@ Example:
|
|
| 137 |
|
| 138 |
== Changelog ==
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
= 4.3.6 =
|
| 141 |
* Fix: woocommerce checkout css
|
| 142 |
|
| 4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 5.2.3
|
| 7 |
+
Stable tag: 4.3.7
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 137 |
|
| 138 |
== Changelog ==
|
| 139 |
|
| 140 |
+
= 4.3.7 =
|
| 141 |
+
* Fix: woocommerce checkout address 2 field required/optional
|
| 142 |
+
* Fix: woocommerce checkout address removed required alert
|
| 143 |
+
|
| 144 |
= 4.3.6 =
|
| 145 |
* Fix: woocommerce checkout css
|
| 146 |
|
woocommerce-checkout-manager.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce Checkout Manager
|
| 4 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
| 5 |
-
* Version: 4.3.
|
| 6 |
* Author: QuadLayers
|
| 7 |
* Author URI: https://www.quadlayers.com
|
| 8 |
* Copyright: 2019 QuadLayers (https://www.quadlayers.com)
|
|
@@ -16,7 +16,7 @@ if (!defined('WOOCCM_PLUGIN_NAME')) {
|
|
| 16 |
define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
|
| 17 |
}
|
| 18 |
if (!defined('WOOCCM_PLUGIN_VERSION')) {
|
| 19 |
-
define('WOOCCM_PLUGIN_VERSION', '4.3.
|
| 20 |
}
|
| 21 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
| 22 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce Checkout Manager
|
| 4 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
| 5 |
+
* Version: 4.3.7
|
| 6 |
* Author: QuadLayers
|
| 7 |
* Author URI: https://www.quadlayers.com
|
| 8 |
* Copyright: 2019 QuadLayers (https://www.quadlayers.com)
|
| 16 |
define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
|
| 17 |
}
|
| 18 |
if (!defined('WOOCCM_PLUGIN_VERSION')) {
|
| 19 |
+
define('WOOCCM_PLUGIN_VERSION', '4.3.7');
|
| 20 |
}
|
| 21 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
| 22 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
