Changeset 3376736
- Timestamp:
- 10/11/2025 04:38:03 PM (6 months ago)
- Location:
- wpos-lite-version
- Files:
-
- 12 edited
-
tags/3.0/includes/Core.php (modified) (27 diffs)
-
tags/3.0/includes/api/Api.php (modified) (3 diffs)
-
tags/3.0/includes/api/Auth.php (modified) (16 diffs)
-
tags/3.0/includes/api/Order.php (modified) (31 diffs)
-
tags/3.0/includes/api/Product.php (modified) (12 diffs)
-
tags/3.0/includes/api/Transaction.php (modified) (8 diffs)
-
trunk/includes/Core.php (modified) (27 diffs)
-
trunk/includes/api/Api.php (modified) (3 diffs)
-
trunk/includes/api/Auth.php (modified) (16 diffs)
-
trunk/includes/api/Order.php (modified) (31 diffs)
-
trunk/includes/api/Product.php (modified) (12 diffs)
-
trunk/includes/api/Transaction.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpos-lite-version/tags/3.0/includes/Core.php
r3373026 r3376736 48 48 //language 49 49 $locale = determine_locale(); 50 unload_textdomain( ' wpos-lite', true );51 load_textdomain( ' wpos-lite', trailingslashit(WPOSL_DIR).'languages/wpos-lite-' . $locale . '.mo' );52 load_plugin_textdomain( ' wpos-lite', false, trailingslashit(WPOSL_DIR).'languages/' );50 unload_textdomain( 'openpos', true ); 51 load_textdomain( 'openpos', trailingslashit(OPENPOS_DIR).'languages/openpos-' . $locale . '.mo' ); 52 load_plugin_textdomain( 'openpos', false, trailingslashit(OPENPOS_DIR).'languages/' ); 53 53 //end 54 54 } … … 104 104 } 105 105 public function getPluginInfo(){ 106 $this->plugin_info = get_plugin_data( WPOSL_DIR.'index.php');106 $this->plugin_info = get_plugin_data(OPENPOS_DIR.'woocommerce-openpos.php'); 107 107 return $this->plugin_info; 108 108 } … … 1310 1310 if( $diff_month > 12 || $diff_day < 0) 1311 1311 { 1312 throw new Exception(__('Time Range is invalid. Maximum is 365 days',' wpos-lite'));1312 throw new Exception(__('Time Range is invalid. Maximum is 365 days','openpos')); 1313 1313 } 1314 1314 } … … 1434 1434 $show_date = sprintf( 1435 1435 /* translators: %s: human-readable time difference */ 1436 _x( '%s ago', '%s = human-readable time difference', ' wpos-lite'),1436 _x( '%s ago', '%s = human-readable time difference', 'openpos' ), 1437 1437 human_time_diff( $order_object->get_date_created()->getTimestamp(), current_time( 'timestamp', true ) ) 1438 1438 ); 1439 1439 } else { 1440 $show_date = $order_object->get_date_created()->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', ' wpos-lite') ) );1440 $show_date = $order_object->get_date_created()->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', 'openpos' ) ) ); 1441 1441 } 1442 1442 return sprintf( … … 1457 1457 $show_date = sprintf( 1458 1458 /* translators: %s: human-readable time difference */ 1459 _x( '%s ago', '%s = human-readable time difference', ' wpos-lite'),1459 _x( '%s ago', '%s = human-readable time difference', 'openpos' ), 1460 1460 human_time_diff( $order_timestamp, current_time( 'timestamp', true ) ) 1461 1461 ); 1462 1462 } else { 1463 $show_date = $WC_DateTime->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', ' wpos-lite') ) );1463 $show_date = $WC_DateTime->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', 'openpos' ) ) ); 1464 1464 } 1465 1465 return sprintf( … … 1485 1485 $payment_options['chip_pin'] = array( 1486 1486 'code' => 'chip_pin', 1487 'admin_title' => __('Chip & PIN',' wpos-lite'),1488 'frontend_title' => __('Chip & PIN',' wpos-lite'),1487 'admin_title' => __('Chip & PIN','openpos'), 1488 'frontend_title' => __('Chip & PIN','openpos'), 1489 1489 'description' => '' 1490 1490 ); … … 1492 1492 // $payment_options['stripe'] = array( 1493 1493 // 'code' => 'stripe', 1494 // 'admin_title' => __('Credit Card ( Stripe ) - Online Payment for POS only',' wpos-lite'),1495 // 'frontend_title' => __('Credit Card',' wpos-lite'),1494 // 'admin_title' => __('Credit Card ( Stripe ) - Online Payment for POS only','openpos'), 1495 // 'frontend_title' => __('Credit Card','openpos'), 1496 1496 // 'description' => '' 1497 1497 // ); … … 1560 1560 if($code == 'chip_pin') 1561 1561 { 1562 $description = __('Click Generate to get a reference order number. Then process the payment using your chip & PIN device.',' wpos-lite');1562 $description = __('Click Generate to get a reference order number. Then process the payment using your chip & PIN device.','openpos'); 1563 1563 $allow_refund = 'offline'; 1564 1564 } … … 1580 1580 function getAllLanguage(){ 1581 1581 $langs = array( 1582 "ab", 1583 "aa", 1584 "af", 1585 "ak", 1586 "sq", 1587 "am", 1588 "ar", 1589 "an", 1590 "hy", 1591 "as", 1592 "av", 1593 "ae", 1594 "ay", 1595 "az", 1596 "bm", 1597 "ba", 1598 "eu", 1599 "be", 1600 "bn", 1601 "bh", 1602 "bi", 1603 "bs", 1604 "br", 1605 "bg", 1606 "my", 1607 "ca", 1608 "ch", 1609 "ce", 1610 "ny", 1611 "zh", 1612 "zh-Hans", 1613 "zh-Hant", 1614 "cv", 1615 "kw", 1616 "co", 1617 "cr", 1618 "hr", 1619 "cs", 1620 "da", 1621 "dv", 1622 "nl", 1623 "dz", 1624 "en", 1625 "eo", 1626 "et", 1627 "ee", 1628 "fo", 1629 "fj", 1630 "fi", 1631 "fr", 1632 "ff", 1633 "gl", 1634 "gd", 1635 "gv", 1636 "ka", 1637 "de", 1638 "el", 1639 "kl", 1640 "gn", 1641 "gu", 1642 "ht", 1643 "ha", 1644 "he", 1645 "hz", 1646 "hi", 1647 "ho", 1648 "hu", 1649 "is", 1650 "io", 1651 "ig", 1652 "id", 1653 "in", 1654 "ia", 1655 "ie", 1656 "iu", 1657 "ik", 1658 "ga", 1659 "it", 1660 "ja", 1661 "jv", 1662 "kl", 1663 "kn", 1664 "kr", 1665 "ks", 1666 "kk", 1667 "km", 1668 "ki", 1669 "rw", 1670 "rn", 1671 "ky", 1672 "kv", 1673 "kg", 1674 "ko", 1675 "ku", 1676 "kj", 1677 "lo", 1678 "la", 1679 "lv", 1680 "li", 1681 "ln", 1682 "lt", 1683 "lu", 1684 "lg", 1685 "lb", 1686 "gv", 1687 "mk", 1688 "mg", 1689 "ms", 1690 "ml", 1691 "mt", 1692 "mi", 1693 "mr", 1694 "mh", 1695 "mo", 1696 "mn", 1697 "na", 1698 "nv", 1699 "ng", 1700 "nd", 1701 "ne", 1702 "no", 1703 "nb", 1704 "nn", 1705 "ii", 1706 "oc", 1707 "oj", 1708 "cu", 1709 "or", 1710 "om", 1711 "os", 1712 "pi", 1713 "ps", 1714 "fa", 1715 "pl", 1716 "pt", 1717 "pa", 1718 "qu", 1719 "rm", 1720 "ro", 1721 "ru", 1722 "se", 1723 "sm", 1724 "sg", 1725 "sa", 1726 "sr", 1727 "sh", 1728 "st", 1729 "tn", 1730 "sn", 1731 "ii", 1732 "sd", 1733 "si", 1734 "ss", 1735 "sk", 1736 "sl", 1737 "so", 1738 "nr", 1739 "es", 1740 "su", 1741 "sw", 1742 "ss", 1743 "sv", 1744 "tl", 1745 "ty", 1746 "tg", 1747 "ta", 1748 "tt", 1749 "te", 1750 "th", 1751 "bo", 1752 "ti", 1753 "to", 1754 "ts", 1755 "tr", 1756 "tk", 1757 "tw", 1758 "ug", 1759 "uk", 1760 "ur", 1761 "uz", 1762 "ve", 1763 "vi", 1764 "vo", 1765 "wa", 1766 "cy", 1767 "wo", 1768 "fy", 1769 "xh", 1770 "yi", 1771 "ji", 1772 "yo", 1773 "za", 1774 "zu", 1582 "ab" => __("Abkhazian", "openpos"), 1583 "aa" => __("Afar", "openpos"), 1584 "af" => __("Afrikaans", "openpos"), 1585 "ak" => __("Akan", "openpos"), 1586 "sq" => __("Albanian", "openpos"), 1587 "am" => __("Amharic", "openpos"), 1588 "ar" => __("Arabic", "openpos"), 1589 "an" => __("Aragonese", "openpos"), 1590 "hy" => __("Armenian", "openpos"), 1591 "as" => __("Assamese", "openpos"), 1592 "av" => __("Avaric", "openpos"), 1593 "ae" => __("Avestan", "openpos"), 1594 "ay" => __("Aymara", "openpos"), 1595 "az" => __("Azerbaijani", "openpos"), 1596 "bm" => __("Bambara", "openpos"), 1597 "ba" => __("Bashkir", "openpos"), 1598 "eu" => __("Basque", "openpos"), 1599 "be" => __("Belarusian", "openpos"), 1600 "bn" => __("Bengali", "openpos"), 1601 "bh" => __("Bihari", "openpos"), 1602 "bi" => __("Bislama", "openpos"), 1603 "bs" => __("Bosnian", "openpos"), 1604 "br" => __("Breton", "openpos"), 1605 "bg" => __("Bulgarian", "openpos"), 1606 "my" => __("Burmese", "openpos"), 1607 "ca" => __("Catalan", "openpos"), 1608 "ch" => __("Chamorro", "openpos"), 1609 "ce" => __("Chechen", "openpos"), 1610 "ny" => __("Chichewa", "openpos"), 1611 "zh" => __("Chinese", "openpos"), 1612 "zh-Hans" => __("Chinese (Simplified)", "openpos"), 1613 "zh-Hant" => __("Chinese (Traditional)", "openpos"), 1614 "cv" => __("Chuvash", "openpos"), 1615 "kw" => __("Cornish", "openpos"), 1616 "co" => __("Corsican", "openpos"), 1617 "cr" => __("Cree", "openpos"), 1618 "hr" => __("Croatian", "openpos"), 1619 "cs" => __("Czech", "openpos"), 1620 "da" => __("Danish", "openpos"), 1621 "dv" => __("Divehi", "openpos"), 1622 "nl" => __("Dutch", "openpos"), 1623 "dz" => __("Dzongkha", "openpos"), 1624 "en" => __("English", "openpos"), 1625 "eo" => __("Esperanto", "openpos"), 1626 "et" => __("Estonian", "openpos"), 1627 "ee" => __("Ewe", "openpos"), 1628 "fo" => __("Faroese", "openpos"), 1629 "fj" => __("Fijian", "openpos"), 1630 "fi" => __("Finnish", "openpos"), 1631 "fr" => __("French", "openpos"), 1632 "ff" => __("Fulah", "openpos"), 1633 "gl" => __("Galician", "openpos"), 1634 "gd" => __("Gaelic", "openpos"), 1635 "gv" => __("Manx", "openpos"), 1636 "ka" => __("Georgian", "openpos"), 1637 "de" => __("German", "openpos"), 1638 "el" => __("Greek", "openpos"), 1639 "kl" => __("Kalaallisut", "openpos"), 1640 "gn" => __("Guarani", "openpos"), 1641 "gu" => __("Gujarati", "openpos"), 1642 "ht" => __("Haitian", "openpos"), 1643 "ha" => __("Hausa", "openpos"), 1644 "he" => __("Hebrew", "openpos"), 1645 "hz" => __("Herero", "openpos"), 1646 "hi" => __("Hindi", "openpos"), 1647 "ho" => __("Hiri Motu", "openpos"), 1648 "hu" => __("Hungarian", "openpos"), 1649 "is" => __("Icelandic", "openpos"), 1650 "io" => __("Ido", "openpos"), 1651 "ig" => __("Igbo", "openpos"), 1652 "id" => __("Indonesian", "openpos"), 1653 "in" => __("Indonesian (old code)", "openpos"), 1654 "ia" => __("Interlingua", "openpos"), 1655 "ie" => __("Interlingue", "openpos"), 1656 "iu" => __("Inuktitut", "openpos"), 1657 "ik" => __("Inupiaq", "openpos"), 1658 "ga" => __("Irish", "openpos"), 1659 "it" => __("Italian", "openpos"), 1660 "ja" => __("Japanese", "openpos"), 1661 "jv" => __("Javanese", "openpos"), 1662 "kn" => __("Kannada", "openpos"), 1663 "kr" => __("Kanuri", "openpos"), 1664 "ks" => __("Kashmiri", "openpos"), 1665 "kk" => __("Kazakh", "openpos"), 1666 "km" => __("Khmer", "openpos"), 1667 "ki" => __("Kikuyu", "openpos"), 1668 "rw" => __("Kinyarwanda", "openpos"), 1669 "rn" => __("Kirundi", "openpos"), 1670 "ky" => __("Kirghiz", "openpos"), 1671 "kv" => __("Komi", "openpos"), 1672 "kg" => __("Kongo", "openpos"), 1673 "ko" => __("Korean", "openpos"), 1674 "ku" => __("Kurdish", "openpos"), 1675 "kj" => __("Kwanyama", "openpos"), 1676 "lo" => __("Lao", "openpos"), 1677 "la" => __("Latin", "openpos"), 1678 "lv" => __("Latvian", "openpos"), 1679 "li" => __("Limburgan", "openpos"), 1680 "ln" => __("Lingala", "openpos"), 1681 "lt" => __("Lithuanian", "openpos"), 1682 "lu" => __("Luba-Katanga", "openpos"), 1683 "lg" => __("Ganda", "openpos"), 1684 "lb" => __("Luxembourgish", "openpos"), 1685 "mk" => __("Macedonian", "openpos"), 1686 "mg" => __("Malagasy", "openpos"), 1687 "ms" => __("Malay", "openpos"), 1688 "ml" => __("Malayalam", "openpos"), 1689 "mt" => __("Maltese", "openpos"), 1690 "mi" => __("Maori", "openpos"), 1691 "mr" => __("Marathi", "openpos"), 1692 "mh" => __("Marshallese", "openpos"), 1693 "mo" => __("Moldavian", "openpos"), 1694 "mn" => __("Mongolian", "openpos"), 1695 "na" => __("Nauru", "openpos"), 1696 "nv" => __("Navajo", "openpos"), 1697 "ng" => __("Ndonga", "openpos"), 1698 "nd" => __("North Ndebele", "openpos"), 1699 "ne" => __("Nepali", "openpos"), 1700 "no" => __("Norwegian", "openpos"), 1701 "nb" => __("Norwegian Bokmål", "openpos"), 1702 "nn" => __("Norwegian Nynorsk", "openpos"), 1703 "ii" => __("Sichuan Yi", "openpos"), 1704 "oc" => __("Occitan", "openpos"), 1705 "oj" => __("Ojibwa", "openpos"), 1706 "cu" => __("Church Slavic", "openpos"), 1707 "or" => __("Oriya", "openpos"), 1708 "om" => __("Oromo", "openpos"), 1709 "os" => __("Ossetian", "openpos"), 1710 "pi" => __("Pali", "openpos"), 1711 "ps" => __("Pashto", "openpos"), 1712 "fa" => __("Persian", "openpos"), 1713 "pl" => __("Polish", "openpos"), 1714 "pt" => __("Portuguese", "openpos"), 1715 "pa" => __("Punjabi", "openpos"), 1716 "qu" => __("Quechua", "openpos"), 1717 "rm" => __("Romansh", "openpos"), 1718 "ro" => __("Romanian", "openpos"), 1719 "ru" => __("Russian", "openpos"), 1720 "se" => __("Northern Sami", "openpos"), 1721 "sm" => __("Samoan", "openpos"), 1722 "sg" => __("Sango", "openpos"), 1723 "sa" => __("Sanskrit", "openpos"), 1724 "sr" => __("Serbian", "openpos"), 1725 "sh" => __("Serbo-Croatian", "openpos"), 1726 "st" => __("Southern Sotho", "openpos"), 1727 "tn" => __("Tswana", "openpos"), 1728 "sn" => __("Shona", "openpos"), 1729 "sd" => __("Sindhi", "openpos"), 1730 "si" => __("Sinhala", "openpos"), 1731 "ss" => __("Swati", "openpos"), 1732 "sk" => __("Slovak", "openpos"), 1733 "sl" => __("Slovenian", "openpos"), 1734 "so" => __("Somali", "openpos"), 1735 "nr" => __("South Ndebele", "openpos"), 1736 "es" => __("Spanish", "openpos"), 1737 "su" => __("Sundanese", "openpos"), 1738 "sw" => __("Swahili", "openpos"), 1739 "sv" => __("Swedish", "openpos"), 1740 "tl" => __("Tagalog", "openpos"), 1741 "ty" => __("Tahitian", "openpos"), 1742 "tg" => __("Tajik", "openpos"), 1743 "ta" => __("Tamil", "openpos"), 1744 "tt" => __("Tatar", "openpos"), 1745 "te" => __("Telugu", "openpos"), 1746 "th" => __("Thai", "openpos"), 1747 "bo" => __("Tibetan", "openpos"), 1748 "ti" => __("Tigrinya", "openpos"), 1749 "to" => __("Tonga", "openpos"), 1750 "ts" => __("Tsonga", "openpos"), 1751 "tr" => __("Turkish", "openpos"), 1752 "tk" => __("Turkmen", "openpos"), 1753 "tw" => __("Twi", "openpos"), 1754 "ug" => __("Uighur", "openpos"), 1755 "uk" => __("Ukrainian", "openpos"), 1756 "ur" => __("Urdu", "openpos"), 1757 "uz" => __("Uzbek", "openpos"), 1758 "ve" => __("Venda", "openpos"), 1759 "vi" => __("Vietnamese", "openpos"), 1760 "vo" => __("Volapük", "openpos"), 1761 "wa" => __("Walloon", "openpos"), 1762 "cy" => __("Welsh", "openpos"), 1763 "wo" => __("Wolof", "openpos"), 1764 "fy" => __("Western Frisian", "openpos"), 1765 "xh" => __("Xhosa", "openpos"), 1766 "yi" => __("Yiddish", "openpos"), 1767 "ji" => __("Yiddish (old code)", "openpos"), 1768 "yo" => __("Yoruba", "openpos"), 1769 "za" => __("Zhuang", "openpos"), 1770 "zu" => __("Zulu", "openpos"), 1775 1771 ); 1776 1772 sort($langs); … … 1778 1774 '_auto' => 'Auto Detect' 1779 1775 ); 1780 foreach($langs as $lang )1781 { 1782 $result[$lang ] = $lang;1776 foreach($langs as $lang_code => $lang) 1777 { 1778 $result[$lang_code] = $lang; 1783 1779 } 1784 1780 … … 1816 1812 public function formatReceiptSetting($setting,$op_incl_tax_mode= false) 1817 1813 { 1818 $payment_methods = '<ul class="payment-methods">'; 1819 $payment_methods .= '<% payment_method.forEach(function(payment){ %>'; 1820 $payment_methods .= '<li><%= payment.name %> : <%= payment.paid %></li>'; 1821 1822 $payment_methods .= '<% if (payment.code == "cash" && payment.return > 0) { %>'; 1823 $payment_methods .= '<li>'.__('Return','wpos-lite').' : <%= payment.return %></li>'; 1824 $payment_methods .= '<% } %>'; 1825 1826 $payment_methods .= '<% }); %>'; 1827 $payment_methods .= '</ul>'; 1828 $rules = array( 1829 '< %' => '<%', 1830 '[customer_name]' => '<%= customer.name %>', 1831 '[customer_phone]' => '<%= customer.phone %>', 1832 '[customer_firstname]' => '<%= customer.firstname %>', 1833 '[customer_lastname]' => '<%= customer.lastname %>', 1834 '[sale_person]' => '<% if(typeof sale_person_name != "undefined") { %> <%= sale_person_name %> <% } %>', 1835 '[created_at]' => '<%= created_at %>', 1836 '[order_number]' => '<%= order_number %>', 1837 '[order_number_format]' => '<%= order_number_format %>', 1838 '[order_note]' => '<%= note %>', 1839 '[customer_email]' => '<%= customer.email %>', 1840 '[payment_method]' => $payment_methods, 1841 ); 1814 1842 1815 1843 1816 //receipt css … … 1860 1833 if(isset($setting['receipt_template_footer'])) 1861 1834 { 1862 $setting['receipt_template_footer'] = str_replace(array_keys($rules), array_values($rules), html_entity_decode($setting['receipt_template_footer']));1835 $setting['receipt_template_footer'] = $this->formatShortcode($setting['receipt_template_footer']); 1863 1836 }else{ 1864 1837 $setting['receipt_template_footer'] = ''; … … 1874 1847 if(isset($setting['receipt_template_header'])) 1875 1848 { 1876 $setting['receipt_template_header'] = str_replace(array_keys($rules), array_values($rules), html_entity_decode($setting['receipt_template_header']));1849 $setting['receipt_template_header'] = $this->formatShortcode($setting['receipt_template_header']); 1877 1850 }else{ 1878 1851 $setting['receipt_template_header'] = ''; … … 1883 1856 1884 1857 1885 $file_path = rtrim( WPOSL_DIR,'/').'/default/'.$file_name;1858 $file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$file_name; 1886 1859 1887 1860 $theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$file_name; … … 1893 1866 { 1894 1867 $file_name = 'receipt_incl_tax_template_body.txt'; 1895 $file_path = rtrim( WPOSL_DIR,'/').'/default/'.$file_name;1868 $file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$file_name; 1896 1869 } 1897 1870 } 1898 1871 $_gift_file_name = 'receipt_gift_template_body.txt'; 1899 $gift_file_path = rtrim( WPOSL_DIR,'/').'/default/'.$_gift_file_name;1872 $gift_file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$_gift_file_name; 1900 1873 1901 1874 $gift_theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$_gift_file_name; … … 1918 1891 $receipt_template = '<table> 1919 1892 <tr class="tabletitle"> 1920 <td class="item"><h2>'.__('Item',' wpos-lite').'</h2></td>1921 <td class="qty"><h2>'.__('Price',' wpos-lite').'</h2></td>1922 <td class="qty"><h2>'.__('Qty',' wpos-lite').'</h2></td>1923 <td class="qty"><h2>'.__('Discount',' wpos-lite').'</h2></td>1924 <td class="total"><h2>'.__('Total',' wpos-lite').'</h2></td>1893 <td class="item"><h2>'.__('Item','openpos' ).'</h2></td> 1894 <td class="qty"><h2>'.__('Price','openpos' ).'</h2></td> 1895 <td class="qty"><h2>'.__('Qty','openpos' ).'</h2></td> 1896 <td class="qty"><h2>'.__('Discount','openpos' ).'</h2></td> 1897 <td class="total"><h2>'.__('Total','openpos' ).'</h2></td> 1925 1898 </tr> 1926 1899 <% items.forEach(function(item){ %> … … 1943 1916 <tr class="tabletitle"> 1944 1917 <td></td> 1945 <td class="Rate sub-total-title" colspan="3"><h2>'.__('Sub Total',' wpos-lite').'</h2></td>1918 <td class="Rate sub-total-title" colspan="3"><h2>'.__('Sub Total','openpos' ).'</h2></td> 1946 1919 <td class="payment sub-total-amount"><h2><%= sub_total %></h2></td> 1947 1920 </tr> … … 1949 1922 <tr class="tabletitle"> 1950 1923 <td></td> 1951 <td class="Rate shipping-title" colspan="3"><h2>'.__('Shipping',' wpos-lite').'</h2></td>1924 <td class="Rate shipping-title" colspan="3"><h2>'.__('Shipping','openpos' ).'</h2></td> 1952 1925 <td class="payment shipping-amount"><h2><%= shipping_cost %></h2></td> 1953 1926 </tr> … … 1955 1928 <tr class="tabletitle"> 1956 1929 <td></td> 1957 <td class="Rate cart-discount-title" colspan="3"><h2>'.__('Discount',' wpos-lite').'</h2></td>1930 <td class="Rate cart-discount-title" colspan="3"><h2>'.__('Discount','openpos' ).'</h2></td> 1958 1931 <td class="payment cart-discount-amount"><h2><%= final_discount_amount %></h2></td> 1959 1932 </tr> 1960 1933 <tr class="tabletitle"> 1961 1934 <td></td> 1962 <td class="Rate tax-title" colspan="3"><h2>'.__('Tax',' wpos-lite').'</h2></td>1935 <td class="Rate tax-title" colspan="3"><h2>'.__('Tax','openpos' ).'</h2></td> 1963 1936 <td class="payment tax-amount"><h2><%= tax_amount %></h2></td> 1964 1937 </tr> 1965 1938 <tr class="tabletitle"> 1966 1939 <td></td> 1967 <td class="Rate grand-total-title" colspan="3"><h2>'.__('Grand Total',' wpos-lite').'</h2></td>1940 <td class="Rate grand-total-title" colspan="3"><h2>'.__('Grand Total','openpos' ).'</h2></td> 1968 1941 <td class="payment grand-total-amount"><h2><%= grand_total %></h2></td> 1969 1942 </tr> … … 2054 2027 if($timezone) 2055 2028 { 2029 // $default_time_zone = date_default_timezone_get(); 2030 // $date = Carbon::createFromFormat('d-m-Y H:i:s', $time_str, $default_time_zone); 2031 // $date->setTimezone($timezone); 2032 // return $date->toDateTimeString(); 2056 2033 return get_date_from_gmt($time_str,'d-m-Y H:i:s'); 2057 2034 }else{ … … 2062 2039 public function getReceiptFontCss(){ 2063 2040 $font_css = array(); 2064 $font_css['receipt_font'] = WPOSL_URL.'/pos/font.css';2041 $font_css['receipt_font'] = OPENPOS_URL.'/pos/font.css'; 2065 2042 return $font_css; 2066 2043 } … … 2184 2161 function get_pos_url($sub_str = ''){ 2185 2162 2186 $pos_url = apply_filters('op_pos_url', 'https://pos.wpos.app');2163 $pos_url = apply_filters('op_pos_url',OPENPOS_URL.'/pos/'); 2187 2164 if($sub_str) 2188 2165 { … … 2192 2169 } 2193 2170 return $pos_url; 2171 } 2172 function get_kitchen_url($wareshouse_id = 0,$base = false){ 2173 2174 $pos_url = apply_filters('op_kitchen_url',OPENPOS_URL.'/kitchen/'); 2175 2176 if(!$base) 2177 { 2178 $pos_url = rtrim($pos_url,'/'); 2179 $site_id = get_current_blog_id(); 2180 if($site_id) 2181 { 2182 $pos_url.= '/index.php?site='.$site_id.'&id='.$wareshouse_id; 2183 }else{ 2184 $pos_url.= '/index.php?id='.$wareshouse_id; 2185 } 2186 2187 } 2188 return $pos_url; 2189 } 2190 function get_bill_url($register_id = 0,$base = false){ 2191 2192 $pos_url = apply_filters('op_bill_url',OPENPOS_URL.'/bill/'); 2193 2194 if(!$base) 2195 { 2196 $pos_url = rtrim($pos_url,'/'); 2197 $site_id = get_current_blog_id(); 2198 if($site_id) 2199 { 2200 $pos_url.= '/index.php?site='.$site_id.'&id='.$register_id; 2201 }else{ 2202 $pos_url.= '/index.php?id='.$register_id; 2203 } 2204 2205 } 2206 2207 return $pos_url; 2208 } 2209 function get_customer_url($params = array()){ 2210 $customer_url = apply_filters('op_customer_url',OPENPOS_URL.'/customer/'); 2211 if(!empty($params)) 2212 { 2213 $params_str = http_build_query($params); 2214 $customer_url = rtrim($customer_url,'/'); 2215 $customer_url .= '/index.php?'.$params_str; 2216 } 2217 return $customer_url; 2194 2218 } 2195 2219 function get_hosting_time($local_time,$client_time_offset = 0){ // in min … … 2215 2239 2216 2240 function plugins_loaded(){ 2217 2241 add_filter( 'rest_request_after_callbacks', function( $response, $handler, $request ) { 2242 if ( is_wp_error( $response ) ) { 2243 $error_code = $response->get_error_code(); 2244 if ( $error_code === 'op_rest_forbidden' ) { 2245 return new WP_REST_Response( [ 2246 'code' => $error_code, 2247 'api_message' => 'You are logged out.', 2248 'response' => array( 2249 'status' => -1, 2250 'message' => $response->get_error_message(), 2251 'data' => array() 2252 ), 2253 ], 200 ); 2254 } 2255 } 2256 2257 return $response; 2258 }, 10, 3 ); 2218 2259 if ( OrderUtil::custom_orders_table_usage_is_enabled() ) { 2219 2260 $this->_enable_hpos = true; … … 2222 2263 } 2223 2264 function getTemplatePath($file_name){ 2224 $templath_dir = 'wpos-lite-version/'; 2265 #$templath_path = OPENPOS_DIR.'templates/emails/'; 2266 $templath_dir = 'woocommerce-openpos/'; 2225 2267 $check_dirs = array( 2226 2268 trailingslashit( get_stylesheet_directory() ) . $templath_dir, … … 2228 2270 trailingslashit( get_stylesheet_directory() ), 2229 2271 trailingslashit( get_template_directory() ), 2230 trailingslashit( WPOSL_DIR ) . 'templates/',2272 trailingslashit( OPENPOS_DIR ) . 'templates/', 2231 2273 ); 2232 2274 foreach ( $check_dirs as $dir ) { … … 2488 2530 } 2489 2531 2532 function rounding_price($price,$decimal=0){ 2533 // get the decimal setting currency 2534 //$decimal = get_option('woocommerce_price_num_decimals',2); 2535 if(!$decimal) 2536 { 2537 $decimal = 0; 2538 } 2539 if(!$price) 2540 { 2541 return $price; 2542 } 2543 $ten_power = pow(10,$decimal); 2544 $price = round($price * $ten_power)/$ten_power; 2545 return $price; 2546 } 2490 2547 2491 2492 2548 2493 2549 } -
wpos-lite-version/tags/3.0/includes/api/Api.php
r3372336 r3376736 78 78 79 79 if ($request && !$this->check_auth_header($request)) { 80 return new WP_Error(' rest_forbidden', __('Unauthorized', 'wpos-lite'), array('status' => 401));80 return new WP_Error('op_rest_forbidden', __('Unauthorized', 'openpos'), array('status' => 0)); 81 81 } 82 82 return true; 83 83 } 84 84 85 protected function check_auth_header(WP_REST_Request $request) { 85 86 $session_id = $request->get_param('session', ''); … … 87 88 { 88 89 $session_data = $this->session_class->data($session_id); 90 $route = $request->get_route(); 91 $source = $request->get_param('source', 'manual'); 92 if(strpos($route,'/auth/logout') !== false && $source === 'remote') 93 { 94 return true; 95 } 89 96 if($session_data) 90 97 { … … 138 145 return floor($number); 139 146 } 147 public function rest_api_limit(WP_REST_Request $request = null){ 148 $result = true; 149 $ip = $_SERVER['REMOTE_ADDR']; 150 $key = 'api_rate_' . md5($ip); 151 152 $limit = apply_filters('rest_api_limit_request',5); // limit 5 requests fail 153 $duration = apply_filters('rest_api_limit_duration',120); // wait 120 seconds 154 155 156 $requests = get_transient($key); 157 if ($requests === false) { 158 $requests = 1; 159 set_transient($key, $requests, $duration); 160 } else { 161 $requests++; 162 set_transient($key, $requests, $duration); 163 } 164 165 if ($requests > $limit) { 166 $result = false; 167 } 168 return $result; 169 } 140 170 141 171 -
wpos-lite-version/tags/3.0/includes/api/Auth.php
r3373026 r3376736 62 62 array( 63 63 'id' => 'openpos_general', 64 'title' => __( 'General', ' wpos-lite')64 'title' => __( 'General', 'openpos' ) 65 65 ), 66 66 array( 67 67 'id' => 'openpos_payment', 68 'title' => __( 'Payment', ' wpos-lite')68 'title' => __( 'Payment', 'openpos' ) 69 69 ), 70 70 array( 71 71 'id' => 'openpos_shipment', 72 'title' => __( 'Shipping', 'wpos-lite') 72 'title' => __( 'Shipping', 'openpos' ) 73 ), 74 array( 75 'id' => 'openpos_label', 76 'title' => __( 'Barcode Label', 'openpos' ) 77 ), 78 array( 79 'id' => 'openpos_receipt', 80 'title' => __( 'Receipt', 'openpos' ) 73 81 ), 74 82 array( 75 83 'id' => 'openpos_pos', 76 'title' => __( 'POS Layout', ' wpos-lite')84 'title' => __( 'POS Layout', 'openpos' ) 77 85 ) 78 86 ); 79 87 80 81 $ignore = array();82 88 $setting = array(); 89 $ignore = array( 90 'stripe_public_key', 91 'stripe_secret_key' 92 ); 93 83 94 foreach($setting_sections as $section) 84 95 { … … 174 185 175 186 } 176 177 $_setting = [ 178 "pos_pwa_enable" => "no", 179 "pos_stock_manage" => "yes", 180 "pos_order_status" => $setting['pos_order_status'], 181 "pos_continue_checkout_order_status" => $setting['pos_continue_checkout_order_status'], 182 "pos_allow_refund" => "no", 183 "allow_exchange" => "no", 184 "pos_tax_class" => "op_productax", 185 "pos_fee_tax_class" => "op_notax", 186 "pos_cart_discount" => "after_tax", 187 "payment_methods" => $setting['payment_methods'], 188 "shipping_methods" => $setting['shipping_methods'], 189 "openpos_type" => "grocery", 190 "dashboard_display" => $setting['dashboard_display'], 191 "openpos_login_mode" => "default", 192 "pos_language" => "_auto", 193 "pos_allow_custom_item" => "no", 194 "pos_allow_custom_note" => "yes", 195 "time_frequency" => "5000", 196 "pos_auto_sync" => "yes", 197 "pos_clear_product" => "yes", 198 "pos_display_outofstock" => "no", 199 "accept_negative_checkout" => "yes", 200 "pos_change_price" => "yes", 201 "pos_image_width" => "208", 202 "pos_image_height" => "195", 203 "pos_categories" => [], 204 "pos_money" => [], 205 "pos_custom_item_discount_amount" => [], 206 "pos_custom_cart_discount_amount" => [], 207 "pos_require_customer_mode" => "no", 208 "pos_customer_autocomplete" => "yes", 209 "pos_search_product_auto" => "yes", 210 "pos_default_open_cash" => "yes", 211 "pos_search_product_online" => "yes", 212 "search_type" => "suggestion", 213 "search_result_total" => "10", 214 "pos_default_checkout_mode" => "single", 215 "pos_enable_weight_barcode" => "no", 216 "pos_laybuy" => "no", 217 "pos_allow_tip" => "no", 218 "pos_tip_amount" => [ ], 219 "pos_allow_online_payment" => "yes", 220 "openpos_tables" => [], 221 "openpos_customer_addition_fields" => [], 222 "pos_incl_tax_mode" => "yes", 223 "pos_prices_include_tax" => "yes", 224 "pos_tax_included_discount" => "yes", 225 "pos_item_incl_tax_mode" => "yes", 226 "pos_tax_details" => $setting['pos_tax_details'], 227 "pos_product_grid_column" => 4, 228 "pos_product_grid_row" => 4, 229 "pos_product_grid_column_sm" => 4, 230 "pos_product_grid_row_sm" => 4, 231 "pos_product_grid_column_xs" => 4, 232 "pos_product_grid_row_xs" => 4, 233 "pos_cat_grid_column" => 4, 234 "pos_cat_grid_row" => 4, 235 "pos_cat_grid_column_sm" => 4, 236 "pos_cat_grid_row_sm" => 4, 237 "pos_cat_grid_column_xs" => 4, 238 "pos_cat_grid_row_xs" => 4, 239 "receipt_gift_template" => '', 240 "receipt_template" => "", 241 "pos_desk_multi_pay" => "yes", 242 "pos_auto_dish_send" => "no", 243 "pos_available_taxes" => $setting['pos_available_taxes'], 244 "currency" => $setting['currency'], 245 "currencies" => $setting['currencies'], 246 "pos_cart_buttons" => [ 247 "cart-note", 248 "shipping", 249 "pickup", 250 "cart-discount", 251 "coupon", 252 "seller", 253 ], 254 "pos_desk_checkout_update" => "no", 255 "pos_cart_item_incl_tax_mode" => "no", 256 "receipt_full_template" => $setting['receipt_full_template'], 257 // "pos_online_order_submit" => "yes", 258 "pos_default_shipping_code" => $setting['pos_default_shipping_code'], 259 "pos_cart_update_event" => "yes", 260 "openpos_customer_basic_fields" => $setting['openpos_customer_basic_fields'], 261 "pos_default_create_customer" => "no", 262 "pos_addition_checkout_fields" => $setting['pos_addition_checkout_fields'], 263 "openpos_product_addition_fields" => [], 264 "pos_money_counter" => [], 265 ]; 266 267 268 $_setting['pos_allow_online_payment'] = $this->core_class->allow_online_payment(); // yes or no 269 270 $_setting['openpos_tables'] = array(); 271 $_setting['payment_methods'] = $this->core_class->formatPaymentMethods($setting['payment_methods']); 272 273 $_setting['shipping_methods'] = $this->woo_class->getStoreShippingMethods($warehouse_id,$setting); 274 187 $setting['pos_allow_online_payment'] = $this->core_class->allow_online_payment(); // yes or no 188 189 190 $setting['openpos_tables'] = array(); 191 $setting['payment_methods'] = $this->core_class->formatPaymentMethods($setting['payment_methods']); 192 193 $setting['shipping_methods'] = $this->woo_class->getStoreShippingMethods($warehouse_id,$setting); 194 if(isset($setting['pos_enable_weight_barcode']) && $setting['pos_enable_weight_barcode'] == 'yes') 195 { 196 $setting['pos_weight_barcode_prefix'] = '20'; 197 } 275 198 276 199 $incl_tax_mode = $this->woo_class->inclTaxMode() == 'yes' ? true : false; 277 $setting = $this->woo_class->_formatSetting($ _setting);278 $setting = $this->core_class->formatReceiptSetting($ _setting,$incl_tax_mode);200 $setting = $this->woo_class->_formatSetting($setting); 201 $setting = $this->core_class->formatReceiptSetting($setting,$incl_tax_mode); 279 202 280 203 return $setting; … … 293 216 294 217 try{ 218 if(!$this->rest_api_limit()) 219 { 220 throw new Exception( __('Your have reach to maximum api request limit. Please try again later.','openpos' )); 221 } 295 222 $username = $request->get_param( 'username' ); 296 223 $password = $request->get_param( 'password' ); … … 340 267 if(!$allow_pos) 341 268 { 342 throw new Exception(__('You have no permission to access POS. Please contact with admin to resolve it.',' wpos-lite'));269 throw new Exception(__('You have no permission to access POS. Please contact with admin to resolve it.','openpos' )); 343 270 } 344 271 345 272 if(!$drawers || empty($drawers)) 346 273 { 347 throw new Exception(__('You have no grant access to any Register POS. Please contact with admin to assign your account to POS Register.',' wpos-lite'));274 throw new Exception(__('You have no grant access to any Register POS. Please contact with admin to assign your account to POS Register.','openpos' )); 348 275 } 349 276 $ip = $this->core_class->getClientIp(); … … 355 282 } 356 283 357 $avatar = rtrim( WPOSL_URL,'/').'/assets/images/default_avatar.png';284 $avatar = rtrim(OPENPOS_URL,'/').'/assets/images/default_avatar.png'; 358 285 359 286 $avatar_args = get_avatar_data( $id); … … 473 400 $session_data['currency_decimal'] = wc_get_price_decimals() ; 474 401 475 $session_data['time_frequency'] = $this->setting_class->get_option('time_frequency','openpos_pos') ? (int)$this->setting_class->get_option('time_frequency','openpos_pos') : 5000 ; 402 $currency_pos = get_option( 'woocommerce_currency_pos' ); 403 $default_currency = array( 404 'decimal' => wc_get_price_decimals(), 405 'decimal_separator' => wc_get_price_decimal_separator(), 406 'thousand_separator' => wc_get_price_thousand_separator(), 407 'currency_pos' => $currency_pos, 408 'code' => get_woocommerce_currency(), 409 'symbol' => html_entity_decode(get_woocommerce_currency_symbol()), 410 'rate' => 1 411 ); 412 $session_data['currency'] = $default_currency; 413 $availble_currencies[$default_currency['code']] = $default_currency; 414 415 $session_data['time_frequency'] = $this->setting_class->get_option('time_frequency','openpos_pos') ? (int)$this->setting_class->get_option('time_frequency','openpos_pos') : 3000 ; 476 416 $session_data['product_sync'] = true; 477 417 $session_data['date_format'] = $this->core_class->convert_to_js_date_format(get_option( 'date_format' )); … … 582 522 $session_data['role'] = $roles; 583 523 //end role 584 $currency_pos = get_option( 'woocommerce_currency_pos' ); 585 $default_currency = array( 586 'decimal' => wc_get_price_decimals(), 587 'decimal_separator' => wc_get_price_decimal_separator(), 588 'thousand_separator' => wc_get_price_thousand_separator(), 589 'currency_pos' => $currency_pos, 590 'code' => get_woocommerce_currency(), 591 'symbol' => html_entity_decode(get_woocommerce_currency_symbol()), 592 'rate' => 1 593 ); 594 $setting['currency'] = $default_currency; 595 $availble_currencies[$default_currency['code']] = $default_currency; 524 596 525 597 526 $setting['currencies'] = $availble_currencies; … … 686 615 if( !$password) 687 616 { 688 throw new Exception(__('PIN can not empty.',' wpos-lite'));617 throw new Exception(__('PIN can not empty.','openpos' )); 689 618 } 690 619 $user = $this->woo_class->pin_authenticate($password,false); … … 705 634 $result['response']['status'] = 1; 706 635 }else{ 707 throw new Exception(__('Your PIN is incorrect. Please try again.',' wpos-lite'));636 throw new Exception(__('Your PIN is incorrect. Please try again.','openpos' )); 708 637 } 709 638 … … 713 642 if(!$password) 714 643 { 715 throw new Exception(__('Please enter password',' wpos-lite'));644 throw new Exception(__('Please enter password','openpos' )); 716 645 } 717 646 718 647 $user = wp_authenticate($username, $password); 719 648 if ( is_wp_error($user) ) { 720 throw new Exception(__('Your password is incorrect. Please try again.',' wpos-lite'));649 throw new Exception(__('Your password is incorrect. Please try again.','openpos' )); 721 650 } 722 651 $result['response']['data'] = array('logon_user_id' => $user->ID,'session_data' =>$session_data); … … 772 701 if(empty($session_data)) 773 702 { 774 throw new Exception(__('Your login session has been clean. Please try login again',' wpos-lite'));703 throw new Exception(__('Your login session has been clean. Please try login again','openpos')); 775 704 } 776 705 $check = true; … … 783 712 $result['response']['status'] = 0; 784 713 $this->session_class->clean($session_id); 785 $result['response']['message'] = __('Your have no grant to any register',' wpos-lite');714 $result['response']['message'] = __('Your have no grant to any register','openpos'); 786 715 } 787 716 $result['code'] = 200; … … 884 813 if($this->setting_class->get_option('openpos_type','openpos_pos') == 'restaurant' ) 885 814 { 886 $tables = $request->get_param('tables') ? $request->get_param('tables') : '';815 $tables = $request->get_param('tables') ? json_decode(stripslashes($request->get_param('tables')),true) : array(); 887 816 888 if( $tables)889 { 890 $_tables = json_decode(stripslashes( $tables),true);891 892 foreach($ _tables as $table_id => $table)817 if(!empty($tables)) 818 { 819 820 821 foreach($tables as $table_id => $table) 893 822 { 894 823 $source_type = isset($table['source_type']) ? $table['source_type'] : ''; … … 898 827 } 899 828 } 900 }901 902 //save to table data903 //disable auto background save item on table904 if(!empty($tables))905 {906 829 $this->table_class->update_bill_screen($tables,true); 907 830 } 908 909 831 910 832 $warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0; … … 921 843 if(!empty($tables_desk_messages)) 922 844 { 923 $desk_message = sprintf(__( 'There are new message from tables: %s', ' wpos-lite'),implode(',',$tables_desk_messages));845 $desk_message = sprintf(__( 'There are new message from tables: %s', 'openpos' ),implode(',',$tables_desk_messages)); 924 846 925 847 } … … 960 882 $result['response']['data'] = array( 961 883 'version' => $this->core_class->_op_version_number(), 962 'type' => 'w pos-lite-version',884 'type' => 'woocommerce-openpos', 963 885 'woo_version' => WC()->version, 964 886 'wp_version' => get_bloginfo( 'version' ), -
wpos-lite-version/tags/3.0/includes/api/Order.php
r3372336 r3376736 248 248 $result['response']['status'] = 1; 249 249 }else{ 250 throw new Exception(__('No order found',' wpos-lite'));250 throw new Exception(__('No order found','openpos')); 251 251 } 252 252 … … 289 289 $result['response']['status'] = 1; 290 290 }else{ 291 throw new Exception(__('Order not found.',' wpos-lite'));291 throw new Exception(__('Order not found.','openpos')); 292 292 } 293 293 $result['code'] = 200; … … 315 315 if(!$order_number) 316 316 { 317 throw new Exception(__('Order number is required',' wpos-lite'));317 throw new Exception(__('Order number is required','openpos')); 318 318 } 319 319 $order_id = $this->order_class->get_order_id_from_number($order_number); 320 320 if(!$order_id) 321 321 { 322 throw new Exception(__('Order not found',' wpos-lite'));322 throw new Exception(__('Order not found','openpos')); 323 323 } 324 324 $order = wc_get_order($order_id); 325 325 if(!$order) 326 326 { 327 throw new Exception(__('Order not found',' wpos-lite'));327 throw new Exception(__('Order not found','openpos')); 328 328 } 329 329 … … 331 331 if(!$formatted_order || empty($formatted_order)) 332 332 { 333 throw new Exception(__('Order not found',' wpos-lite'));333 throw new Exception(__('Order not found','openpos')); 334 334 } 335 335 $result['data']['result'] = $formatted_order; … … 360 360 if(!$local_id) 361 361 { 362 throw new Exception(__('Local ID is required',' wpos-lite'));362 throw new Exception(__('Local ID is required','openpos')); 363 363 } 364 364 $order_id = $this->order_class->get_order_id_from_local_id($local_id); … … 366 366 if(!$order_id) 367 367 { 368 throw new Exception(__('Order not found',' wpos-lite'));368 throw new Exception(__('Order not found','openpos')); 369 369 } 370 370 $order = wc_get_order($order_id); 371 371 if(!$order) 372 372 { 373 throw new Exception(__('Order not found',' wpos-lite'));373 throw new Exception(__('Order not found','openpos')); 374 374 } 375 375 … … 377 377 if(!$formatted_order || empty($formatted_order)) 378 378 { 379 throw new Exception(__('Order not found',' wpos-lite'));379 throw new Exception(__('Order not found','openpos')); 380 380 } 381 381 … … 447 447 if(!$order_id) 448 448 { 449 throw new Exception(__('Order Id is required',' wpos-lite'));449 throw new Exception(__('Order Id is required','openpos')); 450 450 } 451 451 … … 462 462 if(!$order) 463 463 { 464 throw new Exception(__('Order not found',' wpos-lite'));464 throw new Exception(__('Order not found','openpos')); 465 465 } 466 466 $notes = $this->order_class->getOrderNotes($order->get_id()); … … 493 493 $login_cashdrawer_id = isset($session_data['login_cashdrawer_id']) ? $session_data['login_cashdrawer_id'] : 0; 494 494 $order_parse_data = apply_filters('op_new_order_data',$order_data,$session_data); 495 496 497 495 498 $order = $this->order_class->add_order($order_parse_data,$session_data,$is_clear,$order_source); 496 499 … … 510 513 $transaction_data = apply_filters('op_order_transaction_data',$transaction,$order,$order_parse_data); 511 514 $transaction_id = isset($transaction_data['id']) ? $transaction_data['id'] : 0; 515 $done_transient_key = 'done_transaction_'.$transaction_id; 516 $transient_key = 'adding_transaction_'.$transaction_id; 512 517 if($transaction_id) 513 518 { 514 $transient_key = 'adding_transaction_'.$transaction_id;519 515 520 $transaction_data = get_transient($transient_key); 516 if ( false === $transaction_data ) { 521 $done_transaction_data = get_transient($done_transient_key); 522 523 524 if ( false === $transaction_data && false === $done_transaction_data ) { 517 525 $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data); 518 526 $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0; … … 548 556 549 557 } 550 delete_transient( $transient_key );558 551 559 //end 552 560 if($id) … … 565 573 } 566 574 } 575 set_transient( $done_transient_key, $id, DAY_IN_SECONDS ); 567 576 if($is_new) 568 577 { … … 570 579 } 571 580 } 581 delete_transient( $transient_key ); 572 582 } 573 583 } … … 624 634 $result['status'] = 1; 625 635 $result['data'] = $this->woo_class->formatWooOrder($order->get_id()); 626 do_action('op_add_order_final_after',$result[' response']['data']);636 do_action('op_add_order_final_after',$result['data']); 627 637 }else{ 628 throw new Exception(__('Can not create order.',' wpos-lite'));638 throw new Exception(__('Can not create order.','openpos')); 629 639 } 630 640 … … 702 712 if(!$order_id) 703 713 { 704 throw new Exception(__('Order Id is required',' wpos-lite'));714 throw new Exception(__('Order Id is required','openpos')); 705 715 } 706 716 $order = wc_get_order($order_id); … … 934 944 { 935 945 $fee_item = new WC_Order_Item_Fee(); 936 $fee_item->set_name(__('Exchange Fee',' wpos-lite'));946 $fee_item->set_name(__('Exchange Fee','openpos')); 937 947 $fee_item->set_total($_exchange['fee_amount']); 938 948 $fee_item->set_amount($_exchange['fee_amount']); … … 943 953 { 944 954 $fee_item = new WC_Order_Item_Fee(); 945 $fee_item->set_name(__('Addition total for exchange items',' wpos-lite'));955 $fee_item->set_name(__('Addition total for exchange items','openpos')); 946 956 $fee_item->set_total($addition_total); 947 957 $fee_item->set_amount($addition_total); … … 1260 1270 $result['response']['status'] = 1; 1261 1271 }else{ 1262 throw new Exception(__('Order is not found', ' wpos-lite'));1272 throw new Exception(__('Order is not found', 'openpos')); 1263 1273 } 1264 1274 … … 1267 1277 1268 1278 }else{ 1269 throw new Exception( __('Order number too short',' wpos-lite') );1279 throw new Exception( __('Order number too short','openpos') ); 1270 1280 1271 1281 } … … 1331 1341 do_action('op_save_order_note_after',$order_note,$order_status,$order); 1332 1342 }else{ 1333 throw new Exception(__('Order not found.',' wpos-lite'));1343 throw new Exception(__('Order not found.','openpos')); 1334 1344 } 1335 1345 $result['code'] = 200; … … 1365 1375 $result['response'] = $this->receipt_class->send_receipt($send_to,$order_data,$register_id,'manual'); 1366 1376 }else{ 1367 $result['response']['message'] = __('Your email address is incorrect. Please check again!',' wpos-lite');1377 $result['response']['message'] = __('Your email address is incorrect. Please check again!','openpos'); 1368 1378 } 1369 1379 }catch(Exception $e) … … 1414 1424 $result['response']['data'] = $this->woo_class->formatWooOrder($order->get_id()); 1415 1425 }else{ 1416 throw new Exception(__('Order is not found',' wpos-lite'));1426 throw new Exception(__('Order is not found','openpos')); 1417 1427 } 1418 1428 }else{ 1419 throw new Exception(__('Order do not allow pickup from store',' wpos-lite'));1429 throw new Exception(__('Order do not allow pickup from store','openpos')); 1420 1430 } 1421 1431 }catch(Exception $e) … … 1443 1453 if(!$customer_id) 1444 1454 { 1445 throw new Exception(__('Customer do not exist',' wpos-lite'));1455 throw new Exception(__('Customer do not exist','openpos')); 1446 1456 } 1447 1457 $customer = new WC_Customer($customer_id); 1448 1458 if(!$customer) 1449 1459 { 1450 throw new Exception(__('Customer do not exist',' wpos-lite'));1460 throw new Exception(__('Customer do not exist','openpos')); 1451 1461 } 1452 1462 $total_order_count = $customer->get_order_count(); … … 1580 1590 //$pos_order->close_order(); 1581 1591 } 1582 $pos_order->update_status($status ,__('Closed from POS',' wpos-lite'));1592 $pos_order->update_status($status ,__('Closed from POS','openpos')); 1583 1593 1584 1594 $result['response']['status'] = 1; 1585 1595 }else{ 1586 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', ' wpos-lite');1596 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', 'openpos'); 1587 1597 1588 1598 } … … 1590 1600 1591 1601 }else{ 1592 throw new Exception( __('Order is not found', ' wpos-lite'));1602 throw new Exception( __('Order is not found', 'openpos')); 1593 1603 } 1594 1604 1595 1605 }else{ 1596 throw new Exception(__('Order is not found', ' wpos-lite'));1606 throw new Exception(__('Order is not found', 'openpos')); 1597 1607 1598 1608 } … … 1639 1649 $result['response']['data'] = $formatted_order; 1640 1650 $payment_status = $formatted_order['payment_status']; 1641 $result['response']['message'] = __('Payment Status : ',' wpos-lite').$payment_status;1651 $result['response']['message'] = __('Payment Status : ','openpos').$payment_status; 1642 1652 $result['response']['status'] = 1; 1643 1653 }else{ 1644 throw new Exception( __('Order is not found',' wpos-lite') );1654 throw new Exception( __('Order is not found','openpos') ); 1645 1655 } 1646 1656 … … 1649 1659 1650 1660 }else{ 1651 throw new Exception(__('Order number too short',' wpos-lite'));1661 throw new Exception(__('Order number too short','openpos')); 1652 1662 1653 1663 } … … 1717 1727 //$pos_order->close_order(); 1718 1728 } 1719 $pos_order->update_status($status ,__('Closed from POS',' wpos-lite'));1729 $pos_order->update_status($status ,__('Closed from POS','openpos')); 1720 1730 1721 1731 $result['response']['status'] = 1; 1722 1732 }else{ 1723 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', ' wpos-lite');1733 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', 'openpos'); 1724 1734 1725 1735 } … … 1727 1737 1728 1738 }else{ 1729 throw new Exception( __('Order is not found', ' wpos-lite'));1739 throw new Exception( __('Order is not found', 'openpos')); 1730 1740 } 1731 1741 … … 1734 1744 1735 1745 }else{ 1736 throw new Exception(__('Order is not found', ' wpos-lite'));1746 throw new Exception(__('Order is not found', 'openpos')); 1737 1747 1738 1748 } -
wpos-lite-version/tags/3.0/includes/api/Product.php
r3373005 r3376736 52 52 private function _formatApiProduct($product_data,$session_data){ 53 53 return $product_data; 54 54 // $currency = $session_data['setting']['currency']; 55 // $decimal = $currency['decimal']; 56 // $price = $this->_convertToCent($product_data['price'],$decimal); 57 // $priceInclTax = $this->_convertToCent($product_data['price_incl_tax'],$decimal); 58 // $specialPrice = $this->_convertToCent($product_data['special_price'],$decimal); 59 // $options = array(); 60 // $variations = array(); 61 // foreach($product_data['options'] as $option) 62 // { 63 // $options[] = $this->_formatOption($option); 64 // } 65 // foreach($product_data['variations'] as $variation) 66 // { 67 // $variations[] = $this->_formatVariation($variation); 68 // } 69 // $product = array( 70 // 'id' => $product_data['id'], 71 // 'parent_id' => $product_data['parent_id'], 72 // 'parent_product' => null, 73 // 'name' => $product_data['name'], 74 // 'description' => isset($product_data['description']) ? $product_data['description'] : '', 75 // 'sku' => $product_data['sku'], 76 // 'barcode' => $product_data['barcode'], 77 // 'image' => $product_data['image'], 78 // 'group_items' => array(), 79 // 'bundles' => $product_data['bundles'], 80 // 'options' => $options, 81 // 'variations' => $variations, 82 // 'tax' => isset($product_data['tax']) ? $product_data['tax'] : array(), 83 // 'price' => $price, 84 // 'price_incl_tax' => $priceInclTax, 85 // 'price_included_tax' => isset($product_data['price_included_tax']) && $product_data['price_included_tax'] == 1 ? true : false, 86 // 'special_price' => $specialPrice, 87 // 'sale_from' => isset($product_data['special_start_at']) ? $product_data['special_start_at'] : 0, 88 // 'sale_to' => isset($product_data['special_end_at']) ? $product_data['special_end_at'] : 0, 89 // 'discount_rules' => isset($product_data['discount_rules']) ? $product_data['discount_rules'] : array(), 90 // 'stock_status' => $product_data['stock_status'], 91 // 'stock_unit' => isset($product_data['stock_unit']) ? $product_data['stock_unit'] : '', 92 // 'qty' => $product_data['qty'], 93 // 'decimal_qty' => $product_data['decimal_qty'], // number of decimal places for quantity 94 // 'manage_stock' => $product_data['manage_stock'], 95 // 'min_qty' => isset($product_data['min_qty']) ? $product_data['min_qty'] : 0, // Minimum quantity for purchase 96 // 'max_qty' => isset($product_data['max_qty']) ? $product_data['max_qty'] : 0, // Maximum quantity for purchase 97 // 'allow_decal' => isset($product_data['allow_decal']) && $product_data['allow_decal'] == 'yes' ? true : false, 98 // 'allow_change_price' => $product_data['allow_change_price'], 99 // 'product_type' => isset($product_data['product_type']) ? $product_data['product_type'] : '', // product type, simple, variable, bundle, group 100 // 'type' => $product_data['type'], // display type 101 // 'is_featured' => isset($product_data['is_featured']) ? $product_data['is_featured'] : false, // is featured product 102 // 'display' => $product_data['display'], 103 // 'is_searchable' => isset($product_data['is_searchable']) ? $product_data['is_searchable'] : true, // is searchable product 104 // 'categories' => $product_data['categories'], 105 // 'custom_notes' => $product_data['custom_notes'], 106 // 'kitchen_area' => isset($product_data['kitchen_area']) ? $product_data['kitchen_area'] : array(), // kitchen area 107 // 'addition_info' => isset($product_data['addition_info']) ? $product_data['addition_info'] : array(), // kitchen area 108 // ); 109 110 // return $product; 55 111 } 56 112 public function products($request) … … 72 128 $term = sanitize_text_field($term); 73 129 } 74 $per_page = $request->get_param( 'per_page' ) ;130 $per_page = $request->get_param( 'per_page' ) ; 75 131 $page = $request->get_param( 'page' ) ? $request->get_param( 'page' ) : 1; 76 $rowCount = $per_page ? $per_page : 10;132 $rowCount = $per_page ? $per_page : apply_filters('op_load_product_per_page',50); 77 133 $current = $page; 78 134 $offet = ($current -1) * $rowCount; … … 105 161 $data = array('total_page' => $total_page, 'current_page' => $current,'term'=>$term); 106 162 107 $data['product '] = array();163 $data['products'] = array(); 108 164 109 165 $show_out_of_stock = false; … … 188 244 $login_warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0; 189 245 $local_db_version = $request->get_param( 'local_db_version' ) ? $request->get_param( 'local_db_version' ) : 0; 246 $online_db_version = $request->get_param( 'online_db_version' ) ? $request->get_param( 'online_db_version' ) : 0; 247 $page = $request->get_param( 'page' ) ? $request->get_param( 'page' ) : 1; 190 248 $database_version = get_option('_openpos_product_version_'.$login_warehouse_id,0); 191 249 if($local_db_version > 0) 192 250 { 193 $product_changed_data = $this->woo_class->getProductChanged($local_db_version,$login_warehouse_id); 194 195 //throw new Exception(print_r($product_changed_data,true)); 251 $per_page = 50; 196 252 253 $product_changed_data = $this->woo_class->getProductChanged($local_db_version,$login_warehouse_id,$page,$per_page); 254 197 255 $product_ids = array(); 198 256 foreach($product_changed_data['data'] as $product_id => $qty) … … 203 261 $data = array('total_page' => 0,'page' => 0,'version' => $product_changed_data['current_version']); 204 262 205 206 263 $data['product'] = array(); 207 264 $data['delete_product'] = array(); … … 253 310 } 254 311 $version = $product_changed_data['current_version']; 255 312 $found_posts = $product_changed_data['found_posts']; 313 314 $next_page = 1; 256 315 if(empty($data['product']) && $version == 0) 257 316 { 258 317 $version = $database_version; 318 }else{ 319 if($version == $local_db_version) 320 { 321 $next_page = 1 + $page; 322 } 259 323 } 260 324 261 325 $result['response']['data'] = array( 262 326 'products' => $data['product'], 263 'version' => 1*$version 327 'next_page' => $next_page, 328 'version' => $version 264 329 ); 265 330 }else{ 266 331 $result['response']['data'] = array( 267 332 'products' => array(), 268 'version' => 1*$database_version333 'version' => $database_version 269 334 ); 270 335 } … … 311 376 if(!$barcode) 312 377 { 313 throw new Exception(__('Please enter product barcode',' wpos-lite'));378 throw new Exception(__('Please enter product barcode','openpos')); 314 379 } 315 380 $product_id = $this->core_class->getProductIdByBarcode($barcode); … … 365 430 { 366 431 367 throw new Exception(__('Please enter term to search',' wpos-lite'));432 throw new Exception(__('Please enter term to search','openpos')); 368 433 } 369 434 $product_id = $this->core_class->getProductIdByBarcode($term); … … 438 503 $result['code'] = 200; 439 504 $result['response']['status'] = 2; 440 $result['response']['message'] = __('No product found. Please check your barcode !',' wpos-lite');505 $result['response']['message'] = __('No product found. Please check your barcode !','openpos'); 441 506 }else{ 442 507 $result['code'] = 200; … … 468 533 { 469 534 470 throw new Exception(__('Please enter term to search',' wpos-lite'));535 throw new Exception(__('Please enter term to search','openpos')); 471 536 } 472 537 $session_data = $this->session_data; … … 552 617 if(!$term) 553 618 { 554 throw new Exception(__('Please enter barcode to scan',' wpos-lite'));619 throw new Exception(__('Please enter barcode to scan','openpos')); 555 620 } 556 621 $session_data = $this->session_data; … … 578 643 }else{ 579 644 $result['response']['status'] = 0; 580 $result['response']['message'] = sprintf(__('Have no product with barcode "%s". Please check again!',' wpos-lite'),$term);645 $result['response']['message'] = sprintf(__('Have no product with barcode "%s". Please check again!','openpos'),$term); 581 646 } 582 647 $result['response'] = apply_filters('op_get_search_product_result_data',$result['response'],$session_data); -
wpos-lite-version/tags/3.0/includes/api/Transaction.php
r3372336 r3376736 46 46 if(!$register_id) 47 47 { 48 throw new Exception(__('Register not found',' wpos-lite'));48 throw new Exception(__('Register not found','openpos')); 49 49 } 50 50 $order_id_old = $request->get_param('order_id'); … … 128 128 $result['response']['status'] = 1; 129 129 }else{ 130 throw new Exception(__('Order not found.',' wpos-lite'));130 throw new Exception(__('Order not found.','openpos')); 131 131 } 132 132 … … 157 157 158 158 $transaction_id = isset($transaction['id']) ? $transaction['id'] : 0; 159 $transient_key = 'adding_transaction_'.$transaction_id; 160 $done_transient_key = 'done_transaction_'.$transaction_id; 159 161 if($transaction_id) 160 162 { 161 $transient_key = 'adding_transaction_'.$transaction_id; 163 164 $done_transaction_data = get_transient($done_transient_key); 162 165 $transaction_data = get_transient($transient_key); 163 if ( false !== $transaction_data ) { 164 throw new Exception(__('Transaction is being processed. Please wait a moment.','wpos-lite')); 165 } 166 167 $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data); 168 166 if ( false !== $done_transaction_data ) { 167 $result['response']['status'] = 1; 168 $result['response']['data'] = $done_transaction_data; 169 }else{ 170 if ( false !== $transaction_data ) { 171 throw new Exception(__('Transaction is being processed. Please wait a moment.','openpos' )); 172 } 173 174 $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data); 175 176 177 $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0; 178 $out_amount = isset($transaction_data['out_amount']) ? floatval($transaction_data['out_amount']) : 0; 179 $payment_code = isset($transaction_data['payment_code']) ? $transaction_data['payment_code'] : 'cash'; 180 $cashdrawer_id = isset($transaction_data['login_cashdrawer_id']) ? $transaction_data['login_cashdrawer_id'] : 0; 181 $currency = isset($transaction_data['currency']) ? $transaction_data['currency'] : null; 182 $currency_rate = 1; 183 if($currency != null) 184 { 185 if(isset($currency['rate'])) 186 { 187 $currency_rate = 1* $currency['rate']; 188 } 189 } 190 191 set_transient( $transient_key, $transaction_data, MINUTE_IN_SECONDS ); 192 193 //start check transaction exist 194 $exist_transaction = $this->transaction_class->get_by_local_id($transaction_id); 195 196 $id = 0; 197 $is_new = false; 198 if(!$exist_transaction) 199 { 200 201 $id = $this->transaction_class->add($transaction_data); 202 $is_new = true; 203 204 }else{ 205 $transaction = $exist_transaction; 206 $id = $transaction['id']; 207 208 } 209 210 //end 211 if($id) 212 { 213 //add cash drawer balance 214 $is_added_balance = get_post_meta($id,'_add_balance_amount',true); 215 if( $is_new || !$is_added_balance ) 216 { 217 if($payment_code == 'cash') 218 { 219 $balance = ($in_amount - $out_amount) / $currency_rate; 220 221 $this->register_class->addCashBalance($cashdrawer_id,$balance); 169 222 170 $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0; 171 $out_amount = isset($transaction_data['out_amount']) ? floatval($transaction_data['out_amount']) : 0; 172 $payment_code = isset($transaction_data['payment_code']) ? $transaction_data['payment_code'] : 'cash'; 173 $cashdrawer_id = isset($transaction_data['login_cashdrawer_id']) ? $transaction_data['login_cashdrawer_id'] : 0; 174 $currency = isset($transaction_data['currency']) ? $transaction_data['currency'] : null; 175 $currency_rate = 1; 176 if($currency != null) 177 { 178 if(isset($currency['rate'])) 179 { 180 $currency_rate = 1* $currency['rate']; 181 } 182 } 183 184 set_transient( $transient_key, $transaction_data, MINUTE_IN_SECONDS ); 185 186 //start check transaction exist 187 $exist_transaction = $this->transaction_class->get_by_local_id($transaction_id); 188 189 $id = 0; 190 $is_new = false; 191 if(!$exist_transaction) 192 { 193 194 $id = $this->transaction_class->add($transaction_data); 195 $is_new = true; 196 197 }else{ 198 $transaction = $exist_transaction; 199 $id = $transaction['id']; 200 201 } 202 delete_transient( $transient_key ); 203 //end 204 if($id) 205 { 206 //add cash drawer balance 207 $is_added_balance = get_post_meta($id,'_add_balance_amount',true); 208 if( $is_new || !$is_added_balance ) 209 { 210 if($payment_code == 'cash') 223 add_post_meta($id,'_add_balance_amount',$balance); 224 } 225 } 226 set_transient( $done_transient_key, $id, DAY_IN_SECONDS ); 227 $result['response']['status'] = 1; 228 $result['response']['data'] = $id; 229 if($is_new) 211 230 { 212 $balance = ($in_amount - $out_amount) / $currency_rate; 213 214 $this->register_class->addCashBalance($cashdrawer_id,$balance); 215 216 add_post_meta($id,'_add_balance_amount',$balance); 231 do_action('op_add_transaction_after',$id,$session_data,$transaction_data); 217 232 } 218 233 } 219 220 $result['response']['status'] = 1; 221 $result['response']['data'] = $id; 222 if($is_new) 223 { 224 do_action('op_add_transaction_after',$id,$session_data,$transaction_data); 225 } 226 } 234 delete_transient( $transient_key ); 235 } 236 227 237 228 238 } … … 250 260 if(!$transaction_id) 251 261 { 252 throw new Exception(__('Transaction ID is required',' wpos-lite'));262 throw new Exception(__('Transaction ID is required','openpos')); 253 263 } 254 264 $register = isset($this->session_data['register']) ? $this->session_data['register'] : []; 255 265 if(!isset($register['id'])) 256 266 { 257 throw new Exception(__('Register not found',' wpos-lite'));267 throw new Exception(__('Register not found','openpos')); 258 268 } 259 269 $warehouse_id = $register['outlet_id']; … … 261 271 if(!$transaction) 262 272 { 263 throw new Exception(__('Transaction not found',' wpos-lite'));273 throw new Exception(__('Transaction not found','openpos')); 264 274 } 265 275 $result['data']['result'] = $transaction; … … 307 317 { 308 318 309 throw new Exception(__('Order not found',' wpos-lite'));319 throw new Exception(__('Order not found','openpos')); 310 320 } 311 321 $transaction_id = isset($transaction['id']) ? $transaction['id'] : 0; … … 364 374 365 375 $_order->payment_complete(); 366 $_order->set_status($setting_order_status, __('Full Payment via OpenPos', ' wpos-lite'));376 $_order->set_status($setting_order_status, __('Full Payment via OpenPos', 'openpos')); 367 377 368 378 }else{ 369 $note = wp_sprintf(__('Paid amount %s via %s',' wpos-lite'),wc_price($in_amount),$transaction['payment_name']);379 $note = wp_sprintf(__('Paid amount %s via %s','openpos'),wc_price($in_amount),$transaction['payment_name']); 370 380 $this->order_class->addOrderNote($order_id,$note); 371 381 } … … 377 387 ); 378 388 }else{ 379 throw new Exception(wp_sprintf(__('Amount not match with remain amount: %s',' wpos-lite'),$remain_amount));389 throw new Exception(wp_sprintf(__('Amount not match with remain amount: %s','openpos'),$remain_amount)); 380 390 } 381 391 382 392 }else{ 383 throw new Exception(__('Amount value is incorrect',' wpos-lite'));393 throw new Exception(__('Amount value is incorrect','openpos')); 384 394 } 385 395 $result['code'] = 200; -
wpos-lite-version/trunk/includes/Core.php
r3373027 r3376736 48 48 //language 49 49 $locale = determine_locale(); 50 unload_textdomain( ' wpos-lite', true );51 load_textdomain( ' wpos-lite', trailingslashit(WPOSL_DIR).'languages/wpos-lite-' . $locale . '.mo' );52 load_plugin_textdomain( ' wpos-lite', false, trailingslashit(WPOSL_DIR).'languages/' );50 unload_textdomain( 'openpos', true ); 51 load_textdomain( 'openpos', trailingslashit(OPENPOS_DIR).'languages/openpos-' . $locale . '.mo' ); 52 load_plugin_textdomain( 'openpos', false, trailingslashit(OPENPOS_DIR).'languages/' ); 53 53 //end 54 54 } … … 104 104 } 105 105 public function getPluginInfo(){ 106 $this->plugin_info = get_plugin_data( WPOSL_DIR.'index.php');106 $this->plugin_info = get_plugin_data(OPENPOS_DIR.'woocommerce-openpos.php'); 107 107 return $this->plugin_info; 108 108 } … … 1310 1310 if( $diff_month > 12 || $diff_day < 0) 1311 1311 { 1312 throw new Exception(__('Time Range is invalid. Maximum is 365 days',' wpos-lite'));1312 throw new Exception(__('Time Range is invalid. Maximum is 365 days','openpos')); 1313 1313 } 1314 1314 } … … 1434 1434 $show_date = sprintf( 1435 1435 /* translators: %s: human-readable time difference */ 1436 _x( '%s ago', '%s = human-readable time difference', ' wpos-lite'),1436 _x( '%s ago', '%s = human-readable time difference', 'openpos' ), 1437 1437 human_time_diff( $order_object->get_date_created()->getTimestamp(), current_time( 'timestamp', true ) ) 1438 1438 ); 1439 1439 } else { 1440 $show_date = $order_object->get_date_created()->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', ' wpos-lite') ) );1440 $show_date = $order_object->get_date_created()->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', 'openpos' ) ) ); 1441 1441 } 1442 1442 return sprintf( … … 1457 1457 $show_date = sprintf( 1458 1458 /* translators: %s: human-readable time difference */ 1459 _x( '%s ago', '%s = human-readable time difference', ' wpos-lite'),1459 _x( '%s ago', '%s = human-readable time difference', 'openpos' ), 1460 1460 human_time_diff( $order_timestamp, current_time( 'timestamp', true ) ) 1461 1461 ); 1462 1462 } else { 1463 $show_date = $WC_DateTime->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', ' wpos-lite') ) );1463 $show_date = $WC_DateTime->date_i18n( apply_filters( 'woocommerce_admin_order_date_format', __( 'M j, Y', 'openpos' ) ) ); 1464 1464 } 1465 1465 return sprintf( … … 1485 1485 $payment_options['chip_pin'] = array( 1486 1486 'code' => 'chip_pin', 1487 'admin_title' => __('Chip & PIN',' wpos-lite'),1488 'frontend_title' => __('Chip & PIN',' wpos-lite'),1487 'admin_title' => __('Chip & PIN','openpos'), 1488 'frontend_title' => __('Chip & PIN','openpos'), 1489 1489 'description' => '' 1490 1490 ); … … 1492 1492 // $payment_options['stripe'] = array( 1493 1493 // 'code' => 'stripe', 1494 // 'admin_title' => __('Credit Card ( Stripe ) - Online Payment for POS only',' wpos-lite'),1495 // 'frontend_title' => __('Credit Card',' wpos-lite'),1494 // 'admin_title' => __('Credit Card ( Stripe ) - Online Payment for POS only','openpos'), 1495 // 'frontend_title' => __('Credit Card','openpos'), 1496 1496 // 'description' => '' 1497 1497 // ); … … 1560 1560 if($code == 'chip_pin') 1561 1561 { 1562 $description = __('Click Generate to get a reference order number. Then process the payment using your chip & PIN device.',' wpos-lite');1562 $description = __('Click Generate to get a reference order number. Then process the payment using your chip & PIN device.','openpos'); 1563 1563 $allow_refund = 'offline'; 1564 1564 } … … 1580 1580 function getAllLanguage(){ 1581 1581 $langs = array( 1582 "ab", 1583 "aa", 1584 "af", 1585 "ak", 1586 "sq", 1587 "am", 1588 "ar", 1589 "an", 1590 "hy", 1591 "as", 1592 "av", 1593 "ae", 1594 "ay", 1595 "az", 1596 "bm", 1597 "ba", 1598 "eu", 1599 "be", 1600 "bn", 1601 "bh", 1602 "bi", 1603 "bs", 1604 "br", 1605 "bg", 1606 "my", 1607 "ca", 1608 "ch", 1609 "ce", 1610 "ny", 1611 "zh", 1612 "zh-Hans", 1613 "zh-Hant", 1614 "cv", 1615 "kw", 1616 "co", 1617 "cr", 1618 "hr", 1619 "cs", 1620 "da", 1621 "dv", 1622 "nl", 1623 "dz", 1624 "en", 1625 "eo", 1626 "et", 1627 "ee", 1628 "fo", 1629 "fj", 1630 "fi", 1631 "fr", 1632 "ff", 1633 "gl", 1634 "gd", 1635 "gv", 1636 "ka", 1637 "de", 1638 "el", 1639 "kl", 1640 "gn", 1641 "gu", 1642 "ht", 1643 "ha", 1644 "he", 1645 "hz", 1646 "hi", 1647 "ho", 1648 "hu", 1649 "is", 1650 "io", 1651 "ig", 1652 "id", 1653 "in", 1654 "ia", 1655 "ie", 1656 "iu", 1657 "ik", 1658 "ga", 1659 "it", 1660 "ja", 1661 "jv", 1662 "kl", 1663 "kn", 1664 "kr", 1665 "ks", 1666 "kk", 1667 "km", 1668 "ki", 1669 "rw", 1670 "rn", 1671 "ky", 1672 "kv", 1673 "kg", 1674 "ko", 1675 "ku", 1676 "kj", 1677 "lo", 1678 "la", 1679 "lv", 1680 "li", 1681 "ln", 1682 "lt", 1683 "lu", 1684 "lg", 1685 "lb", 1686 "gv", 1687 "mk", 1688 "mg", 1689 "ms", 1690 "ml", 1691 "mt", 1692 "mi", 1693 "mr", 1694 "mh", 1695 "mo", 1696 "mn", 1697 "na", 1698 "nv", 1699 "ng", 1700 "nd", 1701 "ne", 1702 "no", 1703 "nb", 1704 "nn", 1705 "ii", 1706 "oc", 1707 "oj", 1708 "cu", 1709 "or", 1710 "om", 1711 "os", 1712 "pi", 1713 "ps", 1714 "fa", 1715 "pl", 1716 "pt", 1717 "pa", 1718 "qu", 1719 "rm", 1720 "ro", 1721 "ru", 1722 "se", 1723 "sm", 1724 "sg", 1725 "sa", 1726 "sr", 1727 "sh", 1728 "st", 1729 "tn", 1730 "sn", 1731 "ii", 1732 "sd", 1733 "si", 1734 "ss", 1735 "sk", 1736 "sl", 1737 "so", 1738 "nr", 1739 "es", 1740 "su", 1741 "sw", 1742 "ss", 1743 "sv", 1744 "tl", 1745 "ty", 1746 "tg", 1747 "ta", 1748 "tt", 1749 "te", 1750 "th", 1751 "bo", 1752 "ti", 1753 "to", 1754 "ts", 1755 "tr", 1756 "tk", 1757 "tw", 1758 "ug", 1759 "uk", 1760 "ur", 1761 "uz", 1762 "ve", 1763 "vi", 1764 "vo", 1765 "wa", 1766 "cy", 1767 "wo", 1768 "fy", 1769 "xh", 1770 "yi", 1771 "ji", 1772 "yo", 1773 "za", 1774 "zu", 1582 "ab" => __("Abkhazian", "openpos"), 1583 "aa" => __("Afar", "openpos"), 1584 "af" => __("Afrikaans", "openpos"), 1585 "ak" => __("Akan", "openpos"), 1586 "sq" => __("Albanian", "openpos"), 1587 "am" => __("Amharic", "openpos"), 1588 "ar" => __("Arabic", "openpos"), 1589 "an" => __("Aragonese", "openpos"), 1590 "hy" => __("Armenian", "openpos"), 1591 "as" => __("Assamese", "openpos"), 1592 "av" => __("Avaric", "openpos"), 1593 "ae" => __("Avestan", "openpos"), 1594 "ay" => __("Aymara", "openpos"), 1595 "az" => __("Azerbaijani", "openpos"), 1596 "bm" => __("Bambara", "openpos"), 1597 "ba" => __("Bashkir", "openpos"), 1598 "eu" => __("Basque", "openpos"), 1599 "be" => __("Belarusian", "openpos"), 1600 "bn" => __("Bengali", "openpos"), 1601 "bh" => __("Bihari", "openpos"), 1602 "bi" => __("Bislama", "openpos"), 1603 "bs" => __("Bosnian", "openpos"), 1604 "br" => __("Breton", "openpos"), 1605 "bg" => __("Bulgarian", "openpos"), 1606 "my" => __("Burmese", "openpos"), 1607 "ca" => __("Catalan", "openpos"), 1608 "ch" => __("Chamorro", "openpos"), 1609 "ce" => __("Chechen", "openpos"), 1610 "ny" => __("Chichewa", "openpos"), 1611 "zh" => __("Chinese", "openpos"), 1612 "zh-Hans" => __("Chinese (Simplified)", "openpos"), 1613 "zh-Hant" => __("Chinese (Traditional)", "openpos"), 1614 "cv" => __("Chuvash", "openpos"), 1615 "kw" => __("Cornish", "openpos"), 1616 "co" => __("Corsican", "openpos"), 1617 "cr" => __("Cree", "openpos"), 1618 "hr" => __("Croatian", "openpos"), 1619 "cs" => __("Czech", "openpos"), 1620 "da" => __("Danish", "openpos"), 1621 "dv" => __("Divehi", "openpos"), 1622 "nl" => __("Dutch", "openpos"), 1623 "dz" => __("Dzongkha", "openpos"), 1624 "en" => __("English", "openpos"), 1625 "eo" => __("Esperanto", "openpos"), 1626 "et" => __("Estonian", "openpos"), 1627 "ee" => __("Ewe", "openpos"), 1628 "fo" => __("Faroese", "openpos"), 1629 "fj" => __("Fijian", "openpos"), 1630 "fi" => __("Finnish", "openpos"), 1631 "fr" => __("French", "openpos"), 1632 "ff" => __("Fulah", "openpos"), 1633 "gl" => __("Galician", "openpos"), 1634 "gd" => __("Gaelic", "openpos"), 1635 "gv" => __("Manx", "openpos"), 1636 "ka" => __("Georgian", "openpos"), 1637 "de" => __("German", "openpos"), 1638 "el" => __("Greek", "openpos"), 1639 "kl" => __("Kalaallisut", "openpos"), 1640 "gn" => __("Guarani", "openpos"), 1641 "gu" => __("Gujarati", "openpos"), 1642 "ht" => __("Haitian", "openpos"), 1643 "ha" => __("Hausa", "openpos"), 1644 "he" => __("Hebrew", "openpos"), 1645 "hz" => __("Herero", "openpos"), 1646 "hi" => __("Hindi", "openpos"), 1647 "ho" => __("Hiri Motu", "openpos"), 1648 "hu" => __("Hungarian", "openpos"), 1649 "is" => __("Icelandic", "openpos"), 1650 "io" => __("Ido", "openpos"), 1651 "ig" => __("Igbo", "openpos"), 1652 "id" => __("Indonesian", "openpos"), 1653 "in" => __("Indonesian (old code)", "openpos"), 1654 "ia" => __("Interlingua", "openpos"), 1655 "ie" => __("Interlingue", "openpos"), 1656 "iu" => __("Inuktitut", "openpos"), 1657 "ik" => __("Inupiaq", "openpos"), 1658 "ga" => __("Irish", "openpos"), 1659 "it" => __("Italian", "openpos"), 1660 "ja" => __("Japanese", "openpos"), 1661 "jv" => __("Javanese", "openpos"), 1662 "kn" => __("Kannada", "openpos"), 1663 "kr" => __("Kanuri", "openpos"), 1664 "ks" => __("Kashmiri", "openpos"), 1665 "kk" => __("Kazakh", "openpos"), 1666 "km" => __("Khmer", "openpos"), 1667 "ki" => __("Kikuyu", "openpos"), 1668 "rw" => __("Kinyarwanda", "openpos"), 1669 "rn" => __("Kirundi", "openpos"), 1670 "ky" => __("Kirghiz", "openpos"), 1671 "kv" => __("Komi", "openpos"), 1672 "kg" => __("Kongo", "openpos"), 1673 "ko" => __("Korean", "openpos"), 1674 "ku" => __("Kurdish", "openpos"), 1675 "kj" => __("Kwanyama", "openpos"), 1676 "lo" => __("Lao", "openpos"), 1677 "la" => __("Latin", "openpos"), 1678 "lv" => __("Latvian", "openpos"), 1679 "li" => __("Limburgan", "openpos"), 1680 "ln" => __("Lingala", "openpos"), 1681 "lt" => __("Lithuanian", "openpos"), 1682 "lu" => __("Luba-Katanga", "openpos"), 1683 "lg" => __("Ganda", "openpos"), 1684 "lb" => __("Luxembourgish", "openpos"), 1685 "mk" => __("Macedonian", "openpos"), 1686 "mg" => __("Malagasy", "openpos"), 1687 "ms" => __("Malay", "openpos"), 1688 "ml" => __("Malayalam", "openpos"), 1689 "mt" => __("Maltese", "openpos"), 1690 "mi" => __("Maori", "openpos"), 1691 "mr" => __("Marathi", "openpos"), 1692 "mh" => __("Marshallese", "openpos"), 1693 "mo" => __("Moldavian", "openpos"), 1694 "mn" => __("Mongolian", "openpos"), 1695 "na" => __("Nauru", "openpos"), 1696 "nv" => __("Navajo", "openpos"), 1697 "ng" => __("Ndonga", "openpos"), 1698 "nd" => __("North Ndebele", "openpos"), 1699 "ne" => __("Nepali", "openpos"), 1700 "no" => __("Norwegian", "openpos"), 1701 "nb" => __("Norwegian Bokmål", "openpos"), 1702 "nn" => __("Norwegian Nynorsk", "openpos"), 1703 "ii" => __("Sichuan Yi", "openpos"), 1704 "oc" => __("Occitan", "openpos"), 1705 "oj" => __("Ojibwa", "openpos"), 1706 "cu" => __("Church Slavic", "openpos"), 1707 "or" => __("Oriya", "openpos"), 1708 "om" => __("Oromo", "openpos"), 1709 "os" => __("Ossetian", "openpos"), 1710 "pi" => __("Pali", "openpos"), 1711 "ps" => __("Pashto", "openpos"), 1712 "fa" => __("Persian", "openpos"), 1713 "pl" => __("Polish", "openpos"), 1714 "pt" => __("Portuguese", "openpos"), 1715 "pa" => __("Punjabi", "openpos"), 1716 "qu" => __("Quechua", "openpos"), 1717 "rm" => __("Romansh", "openpos"), 1718 "ro" => __("Romanian", "openpos"), 1719 "ru" => __("Russian", "openpos"), 1720 "se" => __("Northern Sami", "openpos"), 1721 "sm" => __("Samoan", "openpos"), 1722 "sg" => __("Sango", "openpos"), 1723 "sa" => __("Sanskrit", "openpos"), 1724 "sr" => __("Serbian", "openpos"), 1725 "sh" => __("Serbo-Croatian", "openpos"), 1726 "st" => __("Southern Sotho", "openpos"), 1727 "tn" => __("Tswana", "openpos"), 1728 "sn" => __("Shona", "openpos"), 1729 "sd" => __("Sindhi", "openpos"), 1730 "si" => __("Sinhala", "openpos"), 1731 "ss" => __("Swati", "openpos"), 1732 "sk" => __("Slovak", "openpos"), 1733 "sl" => __("Slovenian", "openpos"), 1734 "so" => __("Somali", "openpos"), 1735 "nr" => __("South Ndebele", "openpos"), 1736 "es" => __("Spanish", "openpos"), 1737 "su" => __("Sundanese", "openpos"), 1738 "sw" => __("Swahili", "openpos"), 1739 "sv" => __("Swedish", "openpos"), 1740 "tl" => __("Tagalog", "openpos"), 1741 "ty" => __("Tahitian", "openpos"), 1742 "tg" => __("Tajik", "openpos"), 1743 "ta" => __("Tamil", "openpos"), 1744 "tt" => __("Tatar", "openpos"), 1745 "te" => __("Telugu", "openpos"), 1746 "th" => __("Thai", "openpos"), 1747 "bo" => __("Tibetan", "openpos"), 1748 "ti" => __("Tigrinya", "openpos"), 1749 "to" => __("Tonga", "openpos"), 1750 "ts" => __("Tsonga", "openpos"), 1751 "tr" => __("Turkish", "openpos"), 1752 "tk" => __("Turkmen", "openpos"), 1753 "tw" => __("Twi", "openpos"), 1754 "ug" => __("Uighur", "openpos"), 1755 "uk" => __("Ukrainian", "openpos"), 1756 "ur" => __("Urdu", "openpos"), 1757 "uz" => __("Uzbek", "openpos"), 1758 "ve" => __("Venda", "openpos"), 1759 "vi" => __("Vietnamese", "openpos"), 1760 "vo" => __("Volapük", "openpos"), 1761 "wa" => __("Walloon", "openpos"), 1762 "cy" => __("Welsh", "openpos"), 1763 "wo" => __("Wolof", "openpos"), 1764 "fy" => __("Western Frisian", "openpos"), 1765 "xh" => __("Xhosa", "openpos"), 1766 "yi" => __("Yiddish", "openpos"), 1767 "ji" => __("Yiddish (old code)", "openpos"), 1768 "yo" => __("Yoruba", "openpos"), 1769 "za" => __("Zhuang", "openpos"), 1770 "zu" => __("Zulu", "openpos"), 1775 1771 ); 1776 1772 sort($langs); … … 1778 1774 '_auto' => 'Auto Detect' 1779 1775 ); 1780 foreach($langs as $lang )1781 { 1782 $result[$lang ] = $lang;1776 foreach($langs as $lang_code => $lang) 1777 { 1778 $result[$lang_code] = $lang; 1783 1779 } 1784 1780 … … 1816 1812 public function formatReceiptSetting($setting,$op_incl_tax_mode= false) 1817 1813 { 1818 $payment_methods = '<ul class="payment-methods">'; 1819 $payment_methods .= '<% payment_method.forEach(function(payment){ %>'; 1820 $payment_methods .= '<li><%= payment.name %> : <%= payment.paid %></li>'; 1821 1822 $payment_methods .= '<% if (payment.code == "cash" && payment.return > 0) { %>'; 1823 $payment_methods .= '<li>'.__('Return','wpos-lite').' : <%= payment.return %></li>'; 1824 $payment_methods .= '<% } %>'; 1825 1826 $payment_methods .= '<% }); %>'; 1827 $payment_methods .= '</ul>'; 1828 $rules = array( 1829 '< %' => '<%', 1830 '[customer_name]' => '<%= customer.name %>', 1831 '[customer_phone]' => '<%= customer.phone %>', 1832 '[customer_firstname]' => '<%= customer.firstname %>', 1833 '[customer_lastname]' => '<%= customer.lastname %>', 1834 '[sale_person]' => '<% if(typeof sale_person_name != "undefined") { %> <%= sale_person_name %> <% } %>', 1835 '[created_at]' => '<%= created_at %>', 1836 '[order_number]' => '<%= order_number %>', 1837 '[order_number_format]' => '<%= order_number_format %>', 1838 '[order_note]' => '<%= note %>', 1839 '[customer_email]' => '<%= customer.email %>', 1840 '[payment_method]' => $payment_methods, 1841 ); 1814 1842 1815 1843 1816 //receipt css … … 1860 1833 if(isset($setting['receipt_template_footer'])) 1861 1834 { 1862 $setting['receipt_template_footer'] = str_replace(array_keys($rules), array_values($rules), html_entity_decode($setting['receipt_template_footer']));1835 $setting['receipt_template_footer'] = $this->formatShortcode($setting['receipt_template_footer']); 1863 1836 }else{ 1864 1837 $setting['receipt_template_footer'] = ''; … … 1874 1847 if(isset($setting['receipt_template_header'])) 1875 1848 { 1876 $setting['receipt_template_header'] = str_replace(array_keys($rules), array_values($rules), html_entity_decode($setting['receipt_template_header']));1849 $setting['receipt_template_header'] = $this->formatShortcode($setting['receipt_template_header']); 1877 1850 }else{ 1878 1851 $setting['receipt_template_header'] = ''; … … 1883 1856 1884 1857 1885 $file_path = rtrim( WPOSL_DIR,'/').'/default/'.$file_name;1858 $file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$file_name; 1886 1859 1887 1860 $theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$file_name; … … 1893 1866 { 1894 1867 $file_name = 'receipt_incl_tax_template_body.txt'; 1895 $file_path = rtrim( WPOSL_DIR,'/').'/default/'.$file_name;1868 $file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$file_name; 1896 1869 } 1897 1870 } 1898 1871 $_gift_file_name = 'receipt_gift_template_body.txt'; 1899 $gift_file_path = rtrim( WPOSL_DIR,'/').'/default/'.$_gift_file_name;1872 $gift_file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$_gift_file_name; 1900 1873 1901 1874 $gift_theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$_gift_file_name; … … 1918 1891 $receipt_template = '<table> 1919 1892 <tr class="tabletitle"> 1920 <td class="item"><h2>'.__('Item',' wpos-lite').'</h2></td>1921 <td class="qty"><h2>'.__('Price',' wpos-lite').'</h2></td>1922 <td class="qty"><h2>'.__('Qty',' wpos-lite').'</h2></td>1923 <td class="qty"><h2>'.__('Discount',' wpos-lite').'</h2></td>1924 <td class="total"><h2>'.__('Total',' wpos-lite').'</h2></td>1893 <td class="item"><h2>'.__('Item','openpos' ).'</h2></td> 1894 <td class="qty"><h2>'.__('Price','openpos' ).'</h2></td> 1895 <td class="qty"><h2>'.__('Qty','openpos' ).'</h2></td> 1896 <td class="qty"><h2>'.__('Discount','openpos' ).'</h2></td> 1897 <td class="total"><h2>'.__('Total','openpos' ).'</h2></td> 1925 1898 </tr> 1926 1899 <% items.forEach(function(item){ %> … … 1943 1916 <tr class="tabletitle"> 1944 1917 <td></td> 1945 <td class="Rate sub-total-title" colspan="3"><h2>'.__('Sub Total',' wpos-lite').'</h2></td>1918 <td class="Rate sub-total-title" colspan="3"><h2>'.__('Sub Total','openpos' ).'</h2></td> 1946 1919 <td class="payment sub-total-amount"><h2><%= sub_total %></h2></td> 1947 1920 </tr> … … 1949 1922 <tr class="tabletitle"> 1950 1923 <td></td> 1951 <td class="Rate shipping-title" colspan="3"><h2>'.__('Shipping',' wpos-lite').'</h2></td>1924 <td class="Rate shipping-title" colspan="3"><h2>'.__('Shipping','openpos' ).'</h2></td> 1952 1925 <td class="payment shipping-amount"><h2><%= shipping_cost %></h2></td> 1953 1926 </tr> … … 1955 1928 <tr class="tabletitle"> 1956 1929 <td></td> 1957 <td class="Rate cart-discount-title" colspan="3"><h2>'.__('Discount',' wpos-lite').'</h2></td>1930 <td class="Rate cart-discount-title" colspan="3"><h2>'.__('Discount','openpos' ).'</h2></td> 1958 1931 <td class="payment cart-discount-amount"><h2><%= final_discount_amount %></h2></td> 1959 1932 </tr> 1960 1933 <tr class="tabletitle"> 1961 1934 <td></td> 1962 <td class="Rate tax-title" colspan="3"><h2>'.__('Tax',' wpos-lite').'</h2></td>1935 <td class="Rate tax-title" colspan="3"><h2>'.__('Tax','openpos' ).'</h2></td> 1963 1936 <td class="payment tax-amount"><h2><%= tax_amount %></h2></td> 1964 1937 </tr> 1965 1938 <tr class="tabletitle"> 1966 1939 <td></td> 1967 <td class="Rate grand-total-title" colspan="3"><h2>'.__('Grand Total',' wpos-lite').'</h2></td>1940 <td class="Rate grand-total-title" colspan="3"><h2>'.__('Grand Total','openpos' ).'</h2></td> 1968 1941 <td class="payment grand-total-amount"><h2><%= grand_total %></h2></td> 1969 1942 </tr> … … 2054 2027 if($timezone) 2055 2028 { 2029 // $default_time_zone = date_default_timezone_get(); 2030 // $date = Carbon::createFromFormat('d-m-Y H:i:s', $time_str, $default_time_zone); 2031 // $date->setTimezone($timezone); 2032 // return $date->toDateTimeString(); 2056 2033 return get_date_from_gmt($time_str,'d-m-Y H:i:s'); 2057 2034 }else{ … … 2062 2039 public function getReceiptFontCss(){ 2063 2040 $font_css = array(); 2064 $font_css['receipt_font'] = WPOSL_URL.'/pos/font.css';2041 $font_css['receipt_font'] = OPENPOS_URL.'/pos/font.css'; 2065 2042 return $font_css; 2066 2043 } … … 2184 2161 function get_pos_url($sub_str = ''){ 2185 2162 2186 $pos_url = apply_filters('op_pos_url', 'https://pos.wpos.app');2163 $pos_url = apply_filters('op_pos_url',OPENPOS_URL.'/pos/'); 2187 2164 if($sub_str) 2188 2165 { … … 2192 2169 } 2193 2170 return $pos_url; 2171 } 2172 function get_kitchen_url($wareshouse_id = 0,$base = false){ 2173 2174 $pos_url = apply_filters('op_kitchen_url',OPENPOS_URL.'/kitchen/'); 2175 2176 if(!$base) 2177 { 2178 $pos_url = rtrim($pos_url,'/'); 2179 $site_id = get_current_blog_id(); 2180 if($site_id) 2181 { 2182 $pos_url.= '/index.php?site='.$site_id.'&id='.$wareshouse_id; 2183 }else{ 2184 $pos_url.= '/index.php?id='.$wareshouse_id; 2185 } 2186 2187 } 2188 return $pos_url; 2189 } 2190 function get_bill_url($register_id = 0,$base = false){ 2191 2192 $pos_url = apply_filters('op_bill_url',OPENPOS_URL.'/bill/'); 2193 2194 if(!$base) 2195 { 2196 $pos_url = rtrim($pos_url,'/'); 2197 $site_id = get_current_blog_id(); 2198 if($site_id) 2199 { 2200 $pos_url.= '/index.php?site='.$site_id.'&id='.$register_id; 2201 }else{ 2202 $pos_url.= '/index.php?id='.$register_id; 2203 } 2204 2205 } 2206 2207 return $pos_url; 2208 } 2209 function get_customer_url($params = array()){ 2210 $customer_url = apply_filters('op_customer_url',OPENPOS_URL.'/customer/'); 2211 if(!empty($params)) 2212 { 2213 $params_str = http_build_query($params); 2214 $customer_url = rtrim($customer_url,'/'); 2215 $customer_url .= '/index.php?'.$params_str; 2216 } 2217 return $customer_url; 2194 2218 } 2195 2219 function get_hosting_time($local_time,$client_time_offset = 0){ // in min … … 2215 2239 2216 2240 function plugins_loaded(){ 2217 2241 add_filter( 'rest_request_after_callbacks', function( $response, $handler, $request ) { 2242 if ( is_wp_error( $response ) ) { 2243 $error_code = $response->get_error_code(); 2244 if ( $error_code === 'op_rest_forbidden' ) { 2245 return new WP_REST_Response( [ 2246 'code' => $error_code, 2247 'api_message' => 'You are logged out.', 2248 'response' => array( 2249 'status' => -1, 2250 'message' => $response->get_error_message(), 2251 'data' => array() 2252 ), 2253 ], 200 ); 2254 } 2255 } 2256 2257 return $response; 2258 }, 10, 3 ); 2218 2259 if ( OrderUtil::custom_orders_table_usage_is_enabled() ) { 2219 2260 $this->_enable_hpos = true; … … 2222 2263 } 2223 2264 function getTemplatePath($file_name){ 2224 $templath_dir = 'wpos-lite-version/'; 2265 #$templath_path = OPENPOS_DIR.'templates/emails/'; 2266 $templath_dir = 'woocommerce-openpos/'; 2225 2267 $check_dirs = array( 2226 2268 trailingslashit( get_stylesheet_directory() ) . $templath_dir, … … 2228 2270 trailingslashit( get_stylesheet_directory() ), 2229 2271 trailingslashit( get_template_directory() ), 2230 trailingslashit( WPOSL_DIR ) . 'templates/',2272 trailingslashit( OPENPOS_DIR ) . 'templates/', 2231 2273 ); 2232 2274 foreach ( $check_dirs as $dir ) { … … 2488 2530 } 2489 2531 2532 function rounding_price($price,$decimal=0){ 2533 // get the decimal setting currency 2534 //$decimal = get_option('woocommerce_price_num_decimals',2); 2535 if(!$decimal) 2536 { 2537 $decimal = 0; 2538 } 2539 if(!$price) 2540 { 2541 return $price; 2542 } 2543 $ten_power = pow(10,$decimal); 2544 $price = round($price * $ten_power)/$ten_power; 2545 return $price; 2546 } 2490 2547 2491 2492 2548 2493 2549 } -
wpos-lite-version/trunk/includes/api/Api.php
r3372360 r3376736 78 78 79 79 if ($request && !$this->check_auth_header($request)) { 80 return new WP_Error(' rest_forbidden', __('Unauthorized', 'wpos-lite'), array('status' => 401));80 return new WP_Error('op_rest_forbidden', __('Unauthorized', 'openpos'), array('status' => 0)); 81 81 } 82 82 return true; 83 83 } 84 84 85 protected function check_auth_header(WP_REST_Request $request) { 85 86 $session_id = $request->get_param('session', ''); … … 87 88 { 88 89 $session_data = $this->session_class->data($session_id); 90 $route = $request->get_route(); 91 $source = $request->get_param('source', 'manual'); 92 if(strpos($route,'/auth/logout') !== false && $source === 'remote') 93 { 94 return true; 95 } 89 96 if($session_data) 90 97 { … … 138 145 return floor($number); 139 146 } 147 public function rest_api_limit(WP_REST_Request $request = null){ 148 $result = true; 149 $ip = $_SERVER['REMOTE_ADDR']; 150 $key = 'api_rate_' . md5($ip); 151 152 $limit = apply_filters('rest_api_limit_request',5); // limit 5 requests fail 153 $duration = apply_filters('rest_api_limit_duration',120); // wait 120 seconds 154 155 156 $requests = get_transient($key); 157 if ($requests === false) { 158 $requests = 1; 159 set_transient($key, $requests, $duration); 160 } else { 161 $requests++; 162 set_transient($key, $requests, $duration); 163 } 164 165 if ($requests > $limit) { 166 $result = false; 167 } 168 return $result; 169 } 140 170 141 171 -
wpos-lite-version/trunk/includes/api/Auth.php
r3373027 r3376736 62 62 array( 63 63 'id' => 'openpos_general', 64 'title' => __( 'General', ' wpos-lite')64 'title' => __( 'General', 'openpos' ) 65 65 ), 66 66 array( 67 67 'id' => 'openpos_payment', 68 'title' => __( 'Payment', ' wpos-lite')68 'title' => __( 'Payment', 'openpos' ) 69 69 ), 70 70 array( 71 71 'id' => 'openpos_shipment', 72 'title' => __( 'Shipping', 'wpos-lite') 72 'title' => __( 'Shipping', 'openpos' ) 73 ), 74 array( 75 'id' => 'openpos_label', 76 'title' => __( 'Barcode Label', 'openpos' ) 77 ), 78 array( 79 'id' => 'openpos_receipt', 80 'title' => __( 'Receipt', 'openpos' ) 73 81 ), 74 82 array( 75 83 'id' => 'openpos_pos', 76 'title' => __( 'POS Layout', ' wpos-lite')84 'title' => __( 'POS Layout', 'openpos' ) 77 85 ) 78 86 ); 79 87 80 81 $ignore = array();82 88 $setting = array(); 89 $ignore = array( 90 'stripe_public_key', 91 'stripe_secret_key' 92 ); 93 83 94 foreach($setting_sections as $section) 84 95 { … … 174 185 175 186 } 176 177 $_setting = [ 178 "pos_pwa_enable" => "no", 179 "pos_stock_manage" => "yes", 180 "pos_order_status" => $setting['pos_order_status'], 181 "pos_continue_checkout_order_status" => $setting['pos_continue_checkout_order_status'], 182 "pos_allow_refund" => "no", 183 "allow_exchange" => "no", 184 "pos_tax_class" => "op_productax", 185 "pos_fee_tax_class" => "op_notax", 186 "pos_cart_discount" => "after_tax", 187 "payment_methods" => $setting['payment_methods'], 188 "shipping_methods" => $setting['shipping_methods'], 189 "openpos_type" => "grocery", 190 "dashboard_display" => $setting['dashboard_display'], 191 "openpos_login_mode" => "default", 192 "pos_language" => "_auto", 193 "pos_allow_custom_item" => "no", 194 "pos_allow_custom_note" => "yes", 195 "time_frequency" => "5000", 196 "pos_auto_sync" => "yes", 197 "pos_clear_product" => "yes", 198 "pos_display_outofstock" => "no", 199 "accept_negative_checkout" => "yes", 200 "pos_change_price" => "yes", 201 "pos_image_width" => "208", 202 "pos_image_height" => "195", 203 "pos_categories" => [], 204 "pos_money" => [], 205 "pos_custom_item_discount_amount" => [], 206 "pos_custom_cart_discount_amount" => [], 207 "pos_require_customer_mode" => "no", 208 "pos_customer_autocomplete" => "yes", 209 "pos_search_product_auto" => "yes", 210 "pos_default_open_cash" => "yes", 211 "pos_search_product_online" => "yes", 212 "search_type" => "suggestion", 213 "search_result_total" => "10", 214 "pos_default_checkout_mode" => "single", 215 "pos_enable_weight_barcode" => "no", 216 "pos_laybuy" => "no", 217 "pos_allow_tip" => "no", 218 "pos_tip_amount" => [ ], 219 "pos_allow_online_payment" => "yes", 220 "openpos_tables" => [], 221 "openpos_customer_addition_fields" => [], 222 "pos_incl_tax_mode" => "yes", 223 "pos_prices_include_tax" => "yes", 224 "pos_tax_included_discount" => "yes", 225 "pos_item_incl_tax_mode" => "yes", 226 "pos_tax_details" => $setting['pos_tax_details'], 227 "pos_product_grid_column" => 4, 228 "pos_product_grid_row" => 4, 229 "pos_product_grid_column_sm" => 4, 230 "pos_product_grid_row_sm" => 4, 231 "pos_product_grid_column_xs" => 4, 232 "pos_product_grid_row_xs" => 4, 233 "pos_cat_grid_column" => 4, 234 "pos_cat_grid_row" => 4, 235 "pos_cat_grid_column_sm" => 4, 236 "pos_cat_grid_row_sm" => 4, 237 "pos_cat_grid_column_xs" => 4, 238 "pos_cat_grid_row_xs" => 4, 239 "receipt_gift_template" => '', 240 "receipt_template" => "", 241 "pos_desk_multi_pay" => "yes", 242 "pos_auto_dish_send" => "no", 243 "pos_available_taxes" => $setting['pos_available_taxes'], 244 "currency" => $setting['currency'], 245 "currencies" => $setting['currencies'], 246 "pos_cart_buttons" => [ 247 "cart-note", 248 "shipping", 249 "pickup", 250 "cart-discount", 251 "coupon", 252 "seller", 253 ], 254 "pos_desk_checkout_update" => "no", 255 "pos_cart_item_incl_tax_mode" => "no", 256 "receipt_full_template" => $setting['receipt_full_template'], 257 // "pos_online_order_submit" => "yes", 258 "pos_default_shipping_code" => $setting['pos_default_shipping_code'], 259 "pos_cart_update_event" => "yes", 260 "openpos_customer_basic_fields" => $setting['openpos_customer_basic_fields'], 261 "pos_default_create_customer" => "no", 262 "pos_addition_checkout_fields" => $setting['pos_addition_checkout_fields'], 263 "openpos_product_addition_fields" => [], 264 "pos_money_counter" => [], 265 ]; 266 267 268 $_setting['pos_allow_online_payment'] = $this->core_class->allow_online_payment(); // yes or no 269 270 $_setting['openpos_tables'] = array(); 271 $_setting['payment_methods'] = $this->core_class->formatPaymentMethods($setting['payment_methods']); 272 273 $_setting['shipping_methods'] = $this->woo_class->getStoreShippingMethods($warehouse_id,$setting); 274 187 $setting['pos_allow_online_payment'] = $this->core_class->allow_online_payment(); // yes or no 188 189 190 $setting['openpos_tables'] = array(); 191 $setting['payment_methods'] = $this->core_class->formatPaymentMethods($setting['payment_methods']); 192 193 $setting['shipping_methods'] = $this->woo_class->getStoreShippingMethods($warehouse_id,$setting); 194 if(isset($setting['pos_enable_weight_barcode']) && $setting['pos_enable_weight_barcode'] == 'yes') 195 { 196 $setting['pos_weight_barcode_prefix'] = '20'; 197 } 275 198 276 199 $incl_tax_mode = $this->woo_class->inclTaxMode() == 'yes' ? true : false; 277 $setting = $this->woo_class->_formatSetting($ _setting);278 $setting = $this->core_class->formatReceiptSetting($ _setting,$incl_tax_mode);200 $setting = $this->woo_class->_formatSetting($setting); 201 $setting = $this->core_class->formatReceiptSetting($setting,$incl_tax_mode); 279 202 280 203 return $setting; … … 293 216 294 217 try{ 218 if(!$this->rest_api_limit()) 219 { 220 throw new Exception( __('Your have reach to maximum api request limit. Please try again later.','openpos' )); 221 } 295 222 $username = $request->get_param( 'username' ); 296 223 $password = $request->get_param( 'password' ); … … 340 267 if(!$allow_pos) 341 268 { 342 throw new Exception(__('You have no permission to access POS. Please contact with admin to resolve it.',' wpos-lite'));269 throw new Exception(__('You have no permission to access POS. Please contact with admin to resolve it.','openpos' )); 343 270 } 344 271 345 272 if(!$drawers || empty($drawers)) 346 273 { 347 throw new Exception(__('You have no grant access to any Register POS. Please contact with admin to assign your account to POS Register.',' wpos-lite'));274 throw new Exception(__('You have no grant access to any Register POS. Please contact with admin to assign your account to POS Register.','openpos' )); 348 275 } 349 276 $ip = $this->core_class->getClientIp(); … … 355 282 } 356 283 357 $avatar = rtrim( WPOSL_URL,'/').'/assets/images/default_avatar.png';284 $avatar = rtrim(OPENPOS_URL,'/').'/assets/images/default_avatar.png'; 358 285 359 286 $avatar_args = get_avatar_data( $id); … … 473 400 $session_data['currency_decimal'] = wc_get_price_decimals() ; 474 401 475 $session_data['time_frequency'] = $this->setting_class->get_option('time_frequency','openpos_pos') ? (int)$this->setting_class->get_option('time_frequency','openpos_pos') : 5000 ; 402 $currency_pos = get_option( 'woocommerce_currency_pos' ); 403 $default_currency = array( 404 'decimal' => wc_get_price_decimals(), 405 'decimal_separator' => wc_get_price_decimal_separator(), 406 'thousand_separator' => wc_get_price_thousand_separator(), 407 'currency_pos' => $currency_pos, 408 'code' => get_woocommerce_currency(), 409 'symbol' => html_entity_decode(get_woocommerce_currency_symbol()), 410 'rate' => 1 411 ); 412 $session_data['currency'] = $default_currency; 413 $availble_currencies[$default_currency['code']] = $default_currency; 414 415 $session_data['time_frequency'] = $this->setting_class->get_option('time_frequency','openpos_pos') ? (int)$this->setting_class->get_option('time_frequency','openpos_pos') : 3000 ; 476 416 $session_data['product_sync'] = true; 477 417 $session_data['date_format'] = $this->core_class->convert_to_js_date_format(get_option( 'date_format' )); … … 582 522 $session_data['role'] = $roles; 583 523 //end role 584 $currency_pos = get_option( 'woocommerce_currency_pos' ); 585 $default_currency = array( 586 'decimal' => wc_get_price_decimals(), 587 'decimal_separator' => wc_get_price_decimal_separator(), 588 'thousand_separator' => wc_get_price_thousand_separator(), 589 'currency_pos' => $currency_pos, 590 'code' => get_woocommerce_currency(), 591 'symbol' => html_entity_decode(get_woocommerce_currency_symbol()), 592 'rate' => 1 593 ); 594 $setting['currency'] = $default_currency; 595 $availble_currencies[$default_currency['code']] = $default_currency; 524 596 525 597 526 $setting['currencies'] = $availble_currencies; … … 686 615 if( !$password) 687 616 { 688 throw new Exception(__('PIN can not empty.',' wpos-lite'));617 throw new Exception(__('PIN can not empty.','openpos' )); 689 618 } 690 619 $user = $this->woo_class->pin_authenticate($password,false); … … 705 634 $result['response']['status'] = 1; 706 635 }else{ 707 throw new Exception(__('Your PIN is incorrect. Please try again.',' wpos-lite'));636 throw new Exception(__('Your PIN is incorrect. Please try again.','openpos' )); 708 637 } 709 638 … … 713 642 if(!$password) 714 643 { 715 throw new Exception(__('Please enter password',' wpos-lite'));644 throw new Exception(__('Please enter password','openpos' )); 716 645 } 717 646 718 647 $user = wp_authenticate($username, $password); 719 648 if ( is_wp_error($user) ) { 720 throw new Exception(__('Your password is incorrect. Please try again.',' wpos-lite'));649 throw new Exception(__('Your password is incorrect. Please try again.','openpos' )); 721 650 } 722 651 $result['response']['data'] = array('logon_user_id' => $user->ID,'session_data' =>$session_data); … … 772 701 if(empty($session_data)) 773 702 { 774 throw new Exception(__('Your login session has been clean. Please try login again',' wpos-lite'));703 throw new Exception(__('Your login session has been clean. Please try login again','openpos')); 775 704 } 776 705 $check = true; … … 783 712 $result['response']['status'] = 0; 784 713 $this->session_class->clean($session_id); 785 $result['response']['message'] = __('Your have no grant to any register',' wpos-lite');714 $result['response']['message'] = __('Your have no grant to any register','openpos'); 786 715 } 787 716 $result['code'] = 200; … … 884 813 if($this->setting_class->get_option('openpos_type','openpos_pos') == 'restaurant' ) 885 814 { 886 $tables = $request->get_param('tables') ? $request->get_param('tables') : '';815 $tables = $request->get_param('tables') ? json_decode(stripslashes($request->get_param('tables')),true) : array(); 887 816 888 if( $tables)889 { 890 $_tables = json_decode(stripslashes( $tables),true);891 892 foreach($ _tables as $table_id => $table)817 if(!empty($tables)) 818 { 819 820 821 foreach($tables as $table_id => $table) 893 822 { 894 823 $source_type = isset($table['source_type']) ? $table['source_type'] : ''; … … 898 827 } 899 828 } 900 }901 902 //save to table data903 //disable auto background save item on table904 if(!empty($tables))905 {906 829 $this->table_class->update_bill_screen($tables,true); 907 830 } 908 909 831 910 832 $warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0; … … 921 843 if(!empty($tables_desk_messages)) 922 844 { 923 $desk_message = sprintf(__( 'There are new message from tables: %s', ' wpos-lite'),implode(',',$tables_desk_messages));845 $desk_message = sprintf(__( 'There are new message from tables: %s', 'openpos' ),implode(',',$tables_desk_messages)); 924 846 925 847 } … … 960 882 $result['response']['data'] = array( 961 883 'version' => $this->core_class->_op_version_number(), 962 'type' => 'w pos-lite-version',884 'type' => 'woocommerce-openpos', 963 885 'woo_version' => WC()->version, 964 886 'wp_version' => get_bloginfo( 'version' ), -
wpos-lite-version/trunk/includes/api/Order.php
r3372360 r3376736 248 248 $result['response']['status'] = 1; 249 249 }else{ 250 throw new Exception(__('No order found',' wpos-lite'));250 throw new Exception(__('No order found','openpos')); 251 251 } 252 252 … … 289 289 $result['response']['status'] = 1; 290 290 }else{ 291 throw new Exception(__('Order not found.',' wpos-lite'));291 throw new Exception(__('Order not found.','openpos')); 292 292 } 293 293 $result['code'] = 200; … … 315 315 if(!$order_number) 316 316 { 317 throw new Exception(__('Order number is required',' wpos-lite'));317 throw new Exception(__('Order number is required','openpos')); 318 318 } 319 319 $order_id = $this->order_class->get_order_id_from_number($order_number); 320 320 if(!$order_id) 321 321 { 322 throw new Exception(__('Order not found',' wpos-lite'));322 throw new Exception(__('Order not found','openpos')); 323 323 } 324 324 $order = wc_get_order($order_id); 325 325 if(!$order) 326 326 { 327 throw new Exception(__('Order not found',' wpos-lite'));327 throw new Exception(__('Order not found','openpos')); 328 328 } 329 329 … … 331 331 if(!$formatted_order || empty($formatted_order)) 332 332 { 333 throw new Exception(__('Order not found',' wpos-lite'));333 throw new Exception(__('Order not found','openpos')); 334 334 } 335 335 $result['data']['result'] = $formatted_order; … … 360 360 if(!$local_id) 361 361 { 362 throw new Exception(__('Local ID is required',' wpos-lite'));362 throw new Exception(__('Local ID is required','openpos')); 363 363 } 364 364 $order_id = $this->order_class->get_order_id_from_local_id($local_id); … … 366 366 if(!$order_id) 367 367 { 368 throw new Exception(__('Order not found',' wpos-lite'));368 throw new Exception(__('Order not found','openpos')); 369 369 } 370 370 $order = wc_get_order($order_id); 371 371 if(!$order) 372 372 { 373 throw new Exception(__('Order not found',' wpos-lite'));373 throw new Exception(__('Order not found','openpos')); 374 374 } 375 375 … … 377 377 if(!$formatted_order || empty($formatted_order)) 378 378 { 379 throw new Exception(__('Order not found',' wpos-lite'));379 throw new Exception(__('Order not found','openpos')); 380 380 } 381 381 … … 447 447 if(!$order_id) 448 448 { 449 throw new Exception(__('Order Id is required',' wpos-lite'));449 throw new Exception(__('Order Id is required','openpos')); 450 450 } 451 451 … … 462 462 if(!$order) 463 463 { 464 throw new Exception(__('Order not found',' wpos-lite'));464 throw new Exception(__('Order not found','openpos')); 465 465 } 466 466 $notes = $this->order_class->getOrderNotes($order->get_id()); … … 493 493 $login_cashdrawer_id = isset($session_data['login_cashdrawer_id']) ? $session_data['login_cashdrawer_id'] : 0; 494 494 $order_parse_data = apply_filters('op_new_order_data',$order_data,$session_data); 495 496 497 495 498 $order = $this->order_class->add_order($order_parse_data,$session_data,$is_clear,$order_source); 496 499 … … 510 513 $transaction_data = apply_filters('op_order_transaction_data',$transaction,$order,$order_parse_data); 511 514 $transaction_id = isset($transaction_data['id']) ? $transaction_data['id'] : 0; 515 $done_transient_key = 'done_transaction_'.$transaction_id; 516 $transient_key = 'adding_transaction_'.$transaction_id; 512 517 if($transaction_id) 513 518 { 514 $transient_key = 'adding_transaction_'.$transaction_id;519 515 520 $transaction_data = get_transient($transient_key); 516 if ( false === $transaction_data ) { 521 $done_transaction_data = get_transient($done_transient_key); 522 523 524 if ( false === $transaction_data && false === $done_transaction_data ) { 517 525 $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data); 518 526 $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0; … … 548 556 549 557 } 550 delete_transient( $transient_key );558 551 559 //end 552 560 if($id) … … 565 573 } 566 574 } 575 set_transient( $done_transient_key, $id, DAY_IN_SECONDS ); 567 576 if($is_new) 568 577 { … … 570 579 } 571 580 } 581 delete_transient( $transient_key ); 572 582 } 573 583 } … … 624 634 $result['status'] = 1; 625 635 $result['data'] = $this->woo_class->formatWooOrder($order->get_id()); 626 do_action('op_add_order_final_after',$result[' response']['data']);636 do_action('op_add_order_final_after',$result['data']); 627 637 }else{ 628 throw new Exception(__('Can not create order.',' wpos-lite'));638 throw new Exception(__('Can not create order.','openpos')); 629 639 } 630 640 … … 702 712 if(!$order_id) 703 713 { 704 throw new Exception(__('Order Id is required',' wpos-lite'));714 throw new Exception(__('Order Id is required','openpos')); 705 715 } 706 716 $order = wc_get_order($order_id); … … 934 944 { 935 945 $fee_item = new WC_Order_Item_Fee(); 936 $fee_item->set_name(__('Exchange Fee',' wpos-lite'));946 $fee_item->set_name(__('Exchange Fee','openpos')); 937 947 $fee_item->set_total($_exchange['fee_amount']); 938 948 $fee_item->set_amount($_exchange['fee_amount']); … … 943 953 { 944 954 $fee_item = new WC_Order_Item_Fee(); 945 $fee_item->set_name(__('Addition total for exchange items',' wpos-lite'));955 $fee_item->set_name(__('Addition total for exchange items','openpos')); 946 956 $fee_item->set_total($addition_total); 947 957 $fee_item->set_amount($addition_total); … … 1260 1270 $result['response']['status'] = 1; 1261 1271 }else{ 1262 throw new Exception(__('Order is not found', ' wpos-lite'));1272 throw new Exception(__('Order is not found', 'openpos')); 1263 1273 } 1264 1274 … … 1267 1277 1268 1278 }else{ 1269 throw new Exception( __('Order number too short',' wpos-lite') );1279 throw new Exception( __('Order number too short','openpos') ); 1270 1280 1271 1281 } … … 1331 1341 do_action('op_save_order_note_after',$order_note,$order_status,$order); 1332 1342 }else{ 1333 throw new Exception(__('Order not found.',' wpos-lite'));1343 throw new Exception(__('Order not found.','openpos')); 1334 1344 } 1335 1345 $result['code'] = 200; … … 1365 1375 $result['response'] = $this->receipt_class->send_receipt($send_to,$order_data,$register_id,'manual'); 1366 1376 }else{ 1367 $result['response']['message'] = __('Your email address is incorrect. Please check again!',' wpos-lite');1377 $result['response']['message'] = __('Your email address is incorrect. Please check again!','openpos'); 1368 1378 } 1369 1379 }catch(Exception $e) … … 1414 1424 $result['response']['data'] = $this->woo_class->formatWooOrder($order->get_id()); 1415 1425 }else{ 1416 throw new Exception(__('Order is not found',' wpos-lite'));1426 throw new Exception(__('Order is not found','openpos')); 1417 1427 } 1418 1428 }else{ 1419 throw new Exception(__('Order do not allow pickup from store',' wpos-lite'));1429 throw new Exception(__('Order do not allow pickup from store','openpos')); 1420 1430 } 1421 1431 }catch(Exception $e) … … 1443 1453 if(!$customer_id) 1444 1454 { 1445 throw new Exception(__('Customer do not exist',' wpos-lite'));1455 throw new Exception(__('Customer do not exist','openpos')); 1446 1456 } 1447 1457 $customer = new WC_Customer($customer_id); 1448 1458 if(!$customer) 1449 1459 { 1450 throw new Exception(__('Customer do not exist',' wpos-lite'));1460 throw new Exception(__('Customer do not exist','openpos')); 1451 1461 } 1452 1462 $total_order_count = $customer->get_order_count(); … … 1580 1590 //$pos_order->close_order(); 1581 1591 } 1582 $pos_order->update_status($status ,__('Closed from POS',' wpos-lite'));1592 $pos_order->update_status($status ,__('Closed from POS','openpos')); 1583 1593 1584 1594 $result['response']['status'] = 1; 1585 1595 }else{ 1586 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', ' wpos-lite');1596 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', 'openpos'); 1587 1597 1588 1598 } … … 1590 1600 1591 1601 }else{ 1592 throw new Exception( __('Order is not found', ' wpos-lite'));1602 throw new Exception( __('Order is not found', 'openpos')); 1593 1603 } 1594 1604 1595 1605 }else{ 1596 throw new Exception(__('Order is not found', ' wpos-lite'));1606 throw new Exception(__('Order is not found', 'openpos')); 1597 1607 1598 1608 } … … 1639 1649 $result['response']['data'] = $formatted_order; 1640 1650 $payment_status = $formatted_order['payment_status']; 1641 $result['response']['message'] = __('Payment Status : ',' wpos-lite').$payment_status;1651 $result['response']['message'] = __('Payment Status : ','openpos').$payment_status; 1642 1652 $result['response']['status'] = 1; 1643 1653 }else{ 1644 throw new Exception( __('Order is not found',' wpos-lite') );1654 throw new Exception( __('Order is not found','openpos') ); 1645 1655 } 1646 1656 … … 1649 1659 1650 1660 }else{ 1651 throw new Exception(__('Order number too short',' wpos-lite'));1661 throw new Exception(__('Order number too short','openpos')); 1652 1662 1653 1663 } … … 1717 1727 //$pos_order->close_order(); 1718 1728 } 1719 $pos_order->update_status($status ,__('Closed from POS',' wpos-lite'));1729 $pos_order->update_status($status ,__('Closed from POS','openpos')); 1720 1730 1721 1731 $result['response']['status'] = 1; 1722 1732 }else{ 1723 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', ' wpos-lite');1733 $result['response']['message'] = __('You can not close a order has been paid! Please complete order by click Check Payment button.', 'openpos'); 1724 1734 1725 1735 } … … 1727 1737 1728 1738 }else{ 1729 throw new Exception( __('Order is not found', ' wpos-lite'));1739 throw new Exception( __('Order is not found', 'openpos')); 1730 1740 } 1731 1741 … … 1734 1744 1735 1745 }else{ 1736 throw new Exception(__('Order is not found', ' wpos-lite'));1746 throw new Exception(__('Order is not found', 'openpos')); 1737 1747 1738 1748 } -
wpos-lite-version/trunk/includes/api/Product.php
r3373004 r3376736 52 52 private function _formatApiProduct($product_data,$session_data){ 53 53 return $product_data; 54 54 // $currency = $session_data['setting']['currency']; 55 // $decimal = $currency['decimal']; 56 // $price = $this->_convertToCent($product_data['price'],$decimal); 57 // $priceInclTax = $this->_convertToCent($product_data['price_incl_tax'],$decimal); 58 // $specialPrice = $this->_convertToCent($product_data['special_price'],$decimal); 59 // $options = array(); 60 // $variations = array(); 61 // foreach($product_data['options'] as $option) 62 // { 63 // $options[] = $this->_formatOption($option); 64 // } 65 // foreach($product_data['variations'] as $variation) 66 // { 67 // $variations[] = $this->_formatVariation($variation); 68 // } 69 // $product = array( 70 // 'id' => $product_data['id'], 71 // 'parent_id' => $product_data['parent_id'], 72 // 'parent_product' => null, 73 // 'name' => $product_data['name'], 74 // 'description' => isset($product_data['description']) ? $product_data['description'] : '', 75 // 'sku' => $product_data['sku'], 76 // 'barcode' => $product_data['barcode'], 77 // 'image' => $product_data['image'], 78 // 'group_items' => array(), 79 // 'bundles' => $product_data['bundles'], 80 // 'options' => $options, 81 // 'variations' => $variations, 82 // 'tax' => isset($product_data['tax']) ? $product_data['tax'] : array(), 83 // 'price' => $price, 84 // 'price_incl_tax' => $priceInclTax, 85 // 'price_included_tax' => isset($product_data['price_included_tax']) && $product_data['price_included_tax'] == 1 ? true : false, 86 // 'special_price' => $specialPrice, 87 // 'sale_from' => isset($product_data['special_start_at']) ? $product_data['special_start_at'] : 0, 88 // 'sale_to' => isset($product_data['special_end_at']) ? $product_data['special_end_at'] : 0, 89 // 'discount_rules' => isset($product_data['discount_rules']) ? $product_data['discount_rules'] : array(), 90 // 'stock_status' => $product_data['stock_status'], 91 // 'stock_unit' => isset($product_data['stock_unit']) ? $product_data['stock_unit'] : '', 92 // 'qty' => $product_data['qty'], 93 // 'decimal_qty' => $product_data['decimal_qty'], // number of decimal places for quantity 94 // 'manage_stock' => $product_data['manage_stock'], 95 // 'min_qty' => isset($product_data['min_qty']) ? $product_data['min_qty'] : 0, // Minimum quantity for purchase 96 // 'max_qty' => isset($product_data['max_qty']) ? $product_data['max_qty'] : 0, // Maximum quantity for purchase 97 // 'allow_decal' => isset($product_data['allow_decal']) && $product_data['allow_decal'] == 'yes' ? true : false, 98 // 'allow_change_price' => $product_data['allow_change_price'], 99 // 'product_type' => isset($product_data['product_type']) ? $product_data['product_type'] : '', // product type, simple, variable, bundle, group 100 // 'type' => $product_data['type'], // display type 101 // 'is_featured' => isset($product_data['is_featured']) ? $product_data['is_featured'] : false, // is featured product 102 // 'display' => $product_data['display'], 103 // 'is_searchable' => isset($product_data['is_searchable']) ? $product_data['is_searchable'] : true, // is searchable product 104 // 'categories' => $product_data['categories'], 105 // 'custom_notes' => $product_data['custom_notes'], 106 // 'kitchen_area' => isset($product_data['kitchen_area']) ? $product_data['kitchen_area'] : array(), // kitchen area 107 // 'addition_info' => isset($product_data['addition_info']) ? $product_data['addition_info'] : array(), // kitchen area 108 // ); 109 110 // return $product; 55 111 } 56 112 public function products($request) … … 72 128 $term = sanitize_text_field($term); 73 129 } 74 $per_page = $request->get_param( 'per_page' ) ;130 $per_page = $request->get_param( 'per_page' ) ; 75 131 $page = $request->get_param( 'page' ) ? $request->get_param( 'page' ) : 1; 76 $rowCount = $per_page ? $per_page : 10;132 $rowCount = $per_page ? $per_page : apply_filters('op_load_product_per_page',50); 77 133 $current = $page; 78 134 $offet = ($current -1) * $rowCount; … … 105 161 $data = array('total_page' => $total_page, 'current_page' => $current,'term'=>$term); 106 162 107 $data['product '] = array();163 $data['products'] = array(); 108 164 109 165 $show_out_of_stock = false; … … 188 244 $login_warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0; 189 245 $local_db_version = $request->get_param( 'local_db_version' ) ? $request->get_param( 'local_db_version' ) : 0; 246 $online_db_version = $request->get_param( 'online_db_version' ) ? $request->get_param( 'online_db_version' ) : 0; 247 $page = $request->get_param( 'page' ) ? $request->get_param( 'page' ) : 1; 190 248 $database_version = get_option('_openpos_product_version_'.$login_warehouse_id,0); 191 249 if($local_db_version > 0) 192 250 { 193 $product_changed_data = $this->woo_class->getProductChanged($local_db_version,$login_warehouse_id); 194 195 //throw new Exception(print_r($product_changed_data,true)); 251 $per_page = 50; 196 252 253 $product_changed_data = $this->woo_class->getProductChanged($local_db_version,$login_warehouse_id,$page,$per_page); 254 197 255 $product_ids = array(); 198 256 foreach($product_changed_data['data'] as $product_id => $qty) … … 203 261 $data = array('total_page' => 0,'page' => 0,'version' => $product_changed_data['current_version']); 204 262 205 206 263 $data['product'] = array(); 207 264 $data['delete_product'] = array(); … … 253 310 } 254 311 $version = $product_changed_data['current_version']; 255 312 $found_posts = $product_changed_data['found_posts']; 313 314 $next_page = 1; 256 315 if(empty($data['product']) && $version == 0) 257 316 { 258 317 $version = $database_version; 318 }else{ 319 if($version == $local_db_version) 320 { 321 $next_page = 1 + $page; 322 } 259 323 } 260 324 261 325 $result['response']['data'] = array( 262 326 'products' => $data['product'], 263 'version' => 1*$version 327 'next_page' => $next_page, 328 'version' => $version 264 329 ); 265 330 }else{ 266 331 $result['response']['data'] = array( 267 332 'products' => array(), 268 'version' => 1*$database_version333 'version' => $database_version 269 334 ); 270 335 } … … 311 376 if(!$barcode) 312 377 { 313 throw new Exception(__('Please enter product barcode',' wpos-lite'));378 throw new Exception(__('Please enter product barcode','openpos')); 314 379 } 315 380 $product_id = $this->core_class->getProductIdByBarcode($barcode); … … 365 430 { 366 431 367 throw new Exception(__('Please enter term to search',' wpos-lite'));432 throw new Exception(__('Please enter term to search','openpos')); 368 433 } 369 434 $product_id = $this->core_class->getProductIdByBarcode($term); … … 438 503 $result['code'] = 200; 439 504 $result['response']['status'] = 2; 440 $result['response']['message'] = __('No product found. Please check your barcode !',' wpos-lite');505 $result['response']['message'] = __('No product found. Please check your barcode !','openpos'); 441 506 }else{ 442 507 $result['code'] = 200; … … 468 533 { 469 534 470 throw new Exception(__('Please enter term to search',' wpos-lite'));535 throw new Exception(__('Please enter term to search','openpos')); 471 536 } 472 537 $session_data = $this->session_data; … … 552 617 if(!$term) 553 618 { 554 throw new Exception(__('Please enter barcode to scan',' wpos-lite'));619 throw new Exception(__('Please enter barcode to scan','openpos')); 555 620 } 556 621 $session_data = $this->session_data; … … 578 643 }else{ 579 644 $result['response']['status'] = 0; 580 $result['response']['message'] = sprintf(__('Have no product with barcode "%s". Please check again!',' wpos-lite'),$term);645 $result['response']['message'] = sprintf(__('Have no product with barcode "%s". Please check again!','openpos'),$term); 581 646 } 582 647 $result['response'] = apply_filters('op_get_search_product_result_data',$result['response'],$session_data); -
wpos-lite-version/trunk/includes/api/Transaction.php
r3372360 r3376736 46 46 if(!$register_id) 47 47 { 48 throw new Exception(__('Register not found',' wpos-lite'));48 throw new Exception(__('Register not found','openpos')); 49 49 } 50 50 $order_id_old = $request->get_param('order_id'); … … 128 128 $result['response']['status'] = 1; 129 129 }else{ 130 throw new Exception(__('Order not found.',' wpos-lite'));130 throw new Exception(__('Order not found.','openpos')); 131 131 } 132 132 … … 157 157 158 158 $transaction_id = isset($transaction['id']) ? $transaction['id'] : 0; 159 $transient_key = 'adding_transaction_'.$transaction_id; 160 $done_transient_key = 'done_transaction_'.$transaction_id; 159 161 if($transaction_id) 160 162 { 161 $transient_key = 'adding_transaction_'.$transaction_id; 163 164 $done_transaction_data = get_transient($done_transient_key); 162 165 $transaction_data = get_transient($transient_key); 163 if ( false !== $transaction_data ) { 164 throw new Exception(__('Transaction is being processed. Please wait a moment.','wpos-lite')); 165 } 166 167 $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data); 168 166 if ( false !== $done_transaction_data ) { 167 $result['response']['status'] = 1; 168 $result['response']['data'] = $done_transaction_data; 169 }else{ 170 if ( false !== $transaction_data ) { 171 throw new Exception(__('Transaction is being processed. Please wait a moment.','openpos' )); 172 } 173 174 $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data); 175 176 177 $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0; 178 $out_amount = isset($transaction_data['out_amount']) ? floatval($transaction_data['out_amount']) : 0; 179 $payment_code = isset($transaction_data['payment_code']) ? $transaction_data['payment_code'] : 'cash'; 180 $cashdrawer_id = isset($transaction_data['login_cashdrawer_id']) ? $transaction_data['login_cashdrawer_id'] : 0; 181 $currency = isset($transaction_data['currency']) ? $transaction_data['currency'] : null; 182 $currency_rate = 1; 183 if($currency != null) 184 { 185 if(isset($currency['rate'])) 186 { 187 $currency_rate = 1* $currency['rate']; 188 } 189 } 190 191 set_transient( $transient_key, $transaction_data, MINUTE_IN_SECONDS ); 192 193 //start check transaction exist 194 $exist_transaction = $this->transaction_class->get_by_local_id($transaction_id); 195 196 $id = 0; 197 $is_new = false; 198 if(!$exist_transaction) 199 { 200 201 $id = $this->transaction_class->add($transaction_data); 202 $is_new = true; 203 204 }else{ 205 $transaction = $exist_transaction; 206 $id = $transaction['id']; 207 208 } 209 210 //end 211 if($id) 212 { 213 //add cash drawer balance 214 $is_added_balance = get_post_meta($id,'_add_balance_amount',true); 215 if( $is_new || !$is_added_balance ) 216 { 217 if($payment_code == 'cash') 218 { 219 $balance = ($in_amount - $out_amount) / $currency_rate; 220 221 $this->register_class->addCashBalance($cashdrawer_id,$balance); 169 222 170 $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0; 171 $out_amount = isset($transaction_data['out_amount']) ? floatval($transaction_data['out_amount']) : 0; 172 $payment_code = isset($transaction_data['payment_code']) ? $transaction_data['payment_code'] : 'cash'; 173 $cashdrawer_id = isset($transaction_data['login_cashdrawer_id']) ? $transaction_data['login_cashdrawer_id'] : 0; 174 $currency = isset($transaction_data['currency']) ? $transaction_data['currency'] : null; 175 $currency_rate = 1; 176 if($currency != null) 177 { 178 if(isset($currency['rate'])) 179 { 180 $currency_rate = 1* $currency['rate']; 181 } 182 } 183 184 set_transient( $transient_key, $transaction_data, MINUTE_IN_SECONDS ); 185 186 //start check transaction exist 187 $exist_transaction = $this->transaction_class->get_by_local_id($transaction_id); 188 189 $id = 0; 190 $is_new = false; 191 if(!$exist_transaction) 192 { 193 194 $id = $this->transaction_class->add($transaction_data); 195 $is_new = true; 196 197 }else{ 198 $transaction = $exist_transaction; 199 $id = $transaction['id']; 200 201 } 202 delete_transient( $transient_key ); 203 //end 204 if($id) 205 { 206 //add cash drawer balance 207 $is_added_balance = get_post_meta($id,'_add_balance_amount',true); 208 if( $is_new || !$is_added_balance ) 209 { 210 if($payment_code == 'cash') 223 add_post_meta($id,'_add_balance_amount',$balance); 224 } 225 } 226 set_transient( $done_transient_key, $id, DAY_IN_SECONDS ); 227 $result['response']['status'] = 1; 228 $result['response']['data'] = $id; 229 if($is_new) 211 230 { 212 $balance = ($in_amount - $out_amount) / $currency_rate; 213 214 $this->register_class->addCashBalance($cashdrawer_id,$balance); 215 216 add_post_meta($id,'_add_balance_amount',$balance); 231 do_action('op_add_transaction_after',$id,$session_data,$transaction_data); 217 232 } 218 233 } 219 220 $result['response']['status'] = 1; 221 $result['response']['data'] = $id; 222 if($is_new) 223 { 224 do_action('op_add_transaction_after',$id,$session_data,$transaction_data); 225 } 226 } 234 delete_transient( $transient_key ); 235 } 236 227 237 228 238 } … … 250 260 if(!$transaction_id) 251 261 { 252 throw new Exception(__('Transaction ID is required',' wpos-lite'));262 throw new Exception(__('Transaction ID is required','openpos')); 253 263 } 254 264 $register = isset($this->session_data['register']) ? $this->session_data['register'] : []; 255 265 if(!isset($register['id'])) 256 266 { 257 throw new Exception(__('Register not found',' wpos-lite'));267 throw new Exception(__('Register not found','openpos')); 258 268 } 259 269 $warehouse_id = $register['outlet_id']; … … 261 271 if(!$transaction) 262 272 { 263 throw new Exception(__('Transaction not found',' wpos-lite'));273 throw new Exception(__('Transaction not found','openpos')); 264 274 } 265 275 $result['data']['result'] = $transaction; … … 307 317 { 308 318 309 throw new Exception(__('Order not found',' wpos-lite'));319 throw new Exception(__('Order not found','openpos')); 310 320 } 311 321 $transaction_id = isset($transaction['id']) ? $transaction['id'] : 0; … … 364 374 365 375 $_order->payment_complete(); 366 $_order->set_status($setting_order_status, __('Full Payment via OpenPos', ' wpos-lite'));376 $_order->set_status($setting_order_status, __('Full Payment via OpenPos', 'openpos')); 367 377 368 378 }else{ 369 $note = wp_sprintf(__('Paid amount %s via %s',' wpos-lite'),wc_price($in_amount),$transaction['payment_name']);379 $note = wp_sprintf(__('Paid amount %s via %s','openpos'),wc_price($in_amount),$transaction['payment_name']); 370 380 $this->order_class->addOrderNote($order_id,$note); 371 381 } … … 377 387 ); 378 388 }else{ 379 throw new Exception(wp_sprintf(__('Amount not match with remain amount: %s',' wpos-lite'),$remain_amount));389 throw new Exception(wp_sprintf(__('Amount not match with remain amount: %s','openpos'),$remain_amount)); 380 390 } 381 391 382 392 }else{ 383 throw new Exception(__('Amount value is incorrect',' wpos-lite'));393 throw new Exception(__('Amount value is incorrect','openpos')); 384 394 } 385 395 $result['code'] = 200;
Note: See TracChangeset
for help on using the changeset viewer.