Plugin Directory

Changeset 3376736


Ignore:
Timestamp:
10/11/2025 04:38:03 PM (6 months ago)
Author:
openpos
Message:

fix for old wc version

Location:
wpos-lite-version
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • wpos-lite-version/tags/3.0/includes/Core.php

    r3373026 r3376736  
    4848        //language
    4949            $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/' );
    5353        //end
    5454    }
     
    104104    }
    105105    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');
    107107        return $this->plugin_info;
    108108    }
     
    13101310            if( $diff_month > 12 || $diff_day < 0)
    13111311            {
    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'));
    13131313            }
    13141314        }
     
    14341434            $show_date = sprintf(
    14351435            /* 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' ),
    14371437                human_time_diff( $order_object->get_date_created()->getTimestamp(), current_time( 'timestamp', true ) )
    14381438            );
    14391439        } 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' ) ) );
    14411441        }
    14421442        return sprintf(
     
    14571457            $show_date = sprintf(
    14581458            /* 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' ),
    14601460                human_time_diff( $order_timestamp, current_time( 'timestamp', true ) )
    14611461            );
    14621462        } 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' ) ) );
    14641464        }
    14651465        return sprintf(
     
    14851485        $payment_options['chip_pin'] = array(
    14861486           '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'),
    14891489            'description' => ''
    14901490        );
     
    14921492        // $payment_options['stripe'] = array(
    14931493        //     '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'),
    14961496        //     'description' => ''
    14971497        // );
     
    15601560                if($code == 'chip_pin')
    15611561                {
    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');
    15631563                    $allow_refund = 'offline';
    15641564                }
     
    15801580    function getAllLanguage(){
    15811581        $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"),
    17751771        );
    17761772        sort($langs);
     
    17781774            '_auto' => 'Auto Detect'
    17791775        );
    1780         foreach($langs as $lang)
    1781         {
    1782             $result[$lang] = $lang;
     1776        foreach($langs as $lang_code => $lang)
     1777        {
     1778            $result[$lang_code] = $lang;
    17831779        }
    17841780
     
    18161812    public function formatReceiptSetting($setting,$op_incl_tax_mode= false)
    18171813    {
    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       
    18421815
    18431816        //receipt css
     
    18601833        if(isset($setting['receipt_template_footer']))
    18611834        {
    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']);
    18631836        }else{
    18641837            $setting['receipt_template_footer'] = '';
     
    18741847        if(isset($setting['receipt_template_header']))
    18751848        {
    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']);
    18771850        }else{
    18781851            $setting['receipt_template_header'] = '';
     
    18831856
    18841857
    1885         $file_path = rtrim(WPOSL_DIR,'/').'/default/'.$file_name;
     1858        $file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$file_name;
    18861859
    18871860        $theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$file_name;
     
    18931866            {
    18941867                $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;
    18961869            }
    18971870        }
    18981871        $_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;
    19001873
    19011874        $gift_theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$_gift_file_name;
     
    19181891            $receipt_template = '<table>
    19191892            <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>
    19251898            </tr>
    19261899            <% items.forEach(function(item){ %>
     
    19431916            <tr class="tabletitle">
    19441917                <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>
    19461919                <td class="payment sub-total-amount"><h2><%= sub_total %></h2></td>
    19471920            </tr>
     
    19491922            <tr class="tabletitle">
    19501923                <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>
    19521925                <td class="payment shipping-amount"><h2><%= shipping_cost %></h2></td>
    19531926            </tr>
     
    19551928            <tr class="tabletitle">
    19561929                <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>
    19581931                <td class="payment cart-discount-amount"><h2><%= final_discount_amount %></h2></td>
    19591932            </tr>
    19601933            <tr class="tabletitle">
    19611934                <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>
    19631936                <td class="payment tax-amount"><h2><%= tax_amount %></h2></td>
    19641937            </tr>
    19651938            <tr class="tabletitle">
    19661939                <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>
    19681941                <td class="payment grand-total-amount"><h2><%= grand_total %></h2></td>
    19691942            </tr>
     
    20542027        if($timezone)
    20552028        {
     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();
    20562033            return get_date_from_gmt($time_str,'d-m-Y H:i:s');
    20572034        }else{
     
    20622039    public function getReceiptFontCss(){
    20632040        $font_css = array();
    2064         $font_css['receipt_font'] = WPOSL_URL.'/pos/font.css';
     2041        $font_css['receipt_font'] = OPENPOS_URL.'/pos/font.css';
    20652042        return $font_css;
    20662043    }
     
    21842161    function get_pos_url($sub_str = ''){
    21852162     
    2186         $pos_url = apply_filters('op_pos_url','https://pos.wpos.app');
     2163        $pos_url = apply_filters('op_pos_url',OPENPOS_URL.'/pos/');
    21872164        if($sub_str)
    21882165        {
     
    21922169        }
    21932170        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;
    21942218    }
    21952219    function get_hosting_time($local_time,$client_time_offset = 0){ // in min
     
    22152239   
    22162240    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 );
    22182259        if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
    22192260           $this->_enable_hpos = true;
     
    22222263    }
    22232264    function getTemplatePath($file_name){
    2224         $templath_dir = 'wpos-lite-version/';
     2265        #$templath_path = OPENPOS_DIR.'templates/emails/';
     2266        $templath_dir = 'woocommerce-openpos/';
    22252267        $check_dirs = array(
    22262268            trailingslashit( get_stylesheet_directory() ) . $templath_dir,
     
    22282270            trailingslashit( get_stylesheet_directory() ),
    22292271            trailingslashit( get_template_directory() ),
    2230             trailingslashit( WPOSL_DIR ) . 'templates/',
     2272            trailingslashit( OPENPOS_DIR ) . 'templates/',
    22312273        );
    22322274        foreach ( $check_dirs as $dir ) {
     
    24882530    }
    24892531
     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    }
    24902547   
    2491    
    24922548
    24932549}
  • wpos-lite-version/tags/3.0/includes/api/Api.php

    r3372336 r3376736  
    7878           
    7979            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));
    8181            }
    8282            return true;
    8383        }
     84       
    8485        protected function check_auth_header(WP_REST_Request $request) {
    8586            $session_id = $request->get_param('session', '');
     
    8788            {
    8889                $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                }
    8996                if($session_data)
    9097                {
     
    138145            return floor($number);
    139146        }
     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        }
    140170       
    141171
  • wpos-lite-version/tags/3.0/includes/api/Auth.php

    r3373026 r3376736  
    6262                array(
    6363                    'id'    => 'openpos_general',
    64                     'title' => __( 'General', 'wpos-lite')
     64                    'title' => __( 'General', 'openpos' )
    6565                ),
    6666                array(
    6767                    'id'    => 'openpos_payment',
    68                     'title' => __( 'Payment', 'wpos-lite')
     68                    'title' => __( 'Payment', 'openpos' )
    6969                ),
    7070                array(
    7171                    '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' )
    7381                ),
    7482                array(
    7583                    'id'    => 'openpos_pos',
    76                     'title' => __( 'POS Layout', 'wpos-lite')
     84                    'title' => __( 'POS Layout', 'openpos' )
    7785                )
    7886            );
    7987           
    80            
    81             $ignore = array();
    8288            $setting = array();
     89            $ignore = array(
     90                'stripe_public_key',
     91                'stripe_secret_key'
     92            );
     93           
    8394            foreach($setting_sections as $section)
    8495            {
     
    174185           
    175186            }
    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            }
    275198
    276199            $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);
    279202           
    280203            return $setting;
     
    293216           
    294217            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                }
    295222                $username = $request->get_param( 'username' );
    296223                $password = $request->get_param( 'password' );
     
    340267                if(!$allow_pos)
    341268                {
    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' ));
    343270                }
    344271
    345272                if(!$drawers || empty($drawers))
    346273                {
    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' ));
    348275                }
    349276                $ip = $this->core_class->getClientIp();
     
    355282                }
    356283               
    357                 $avatar = rtrim(WPOSL_URL,'/').'/assets/images/default_avatar.png';
     284                $avatar = rtrim(OPENPOS_URL,'/').'/assets/images/default_avatar.png';
    358285
    359286                $avatar_args = get_avatar_data( $id);
     
    473400                $session_data['currency_decimal'] = wc_get_price_decimals() ;
    474401
    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 ;
    476416                $session_data['product_sync'] = true;
    477417                $session_data['date_format'] = $this->core_class->convert_to_js_date_format(get_option( 'date_format' ));
     
    582522                $session_data['role'] = $roles;
    583523                //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               
    596525
    597526                $setting['currencies'] = $availble_currencies;
     
    686615                    if( !$password)
    687616                    {
    688                         throw new Exception(__('PIN can not empty.','wpos-lite'));
     617                        throw new Exception(__('PIN can not empty.','openpos' ));
    689618                    }
    690619                    $user = $this->woo_class->pin_authenticate($password,false);
     
    705634                        $result['response']['status'] = 1;
    706635                    }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' ));
    708637                    }
    709638
     
    713642                    if(!$password)
    714643                    {
    715                         throw new Exception(__('Please enter password','wpos-lite'));
     644                        throw new Exception(__('Please enter password','openpos' ));
    716645                    }
    717646                   
    718647                    $user = wp_authenticate($username, $password);
    719648                    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' ));
    721650                    }
    722651                    $result['response']['data'] = array('logon_user_id' => $user->ID,'session_data' =>$session_data);
     
    772701                if(empty($session_data))
    773702                {
    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'));
    775704                }
    776705                $check = true;
     
    783712                    $result['response']['status'] = 0;
    784713                    $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');
    786715                }
    787716                $result['code'] = 200;
     
    884813                if($this->setting_class->get_option('openpos_type','openpos_pos') == 'restaurant' )
    885814                {
    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();
    887816                   
    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)
    893822                        {
    894823                            $source_type = isset($table['source_type']) ? $table['source_type'] : '';
     
    898827                            }
    899828                        }
    900                     }
    901 
    902                     //save to table data
    903                     //disable auto background save item on table
    904                     if(!empty($tables))
    905                     {
    906829                        $this->table_class->update_bill_screen($tables,true);
    907830                    }
    908                    
    909831
    910832                    $warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0;
     
    921843                    if(!empty($tables_desk_messages))
    922844                    {
    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));
    924846                       
    925847                    }
     
    960882                $result['response']['data'] = array(
    961883                    'version' => $this->core_class->_op_version_number(),
    962                     'type' => 'wpos-lite-version',
     884                    'type' => 'woocommerce-openpos',
    963885                    'woo_version' => WC()->version,
    964886                    'wp_version' => get_bloginfo( 'version' ),
  • wpos-lite-version/tags/3.0/includes/api/Order.php

    r3372336 r3376736  
    248248                    $result['response']['status'] = 1;
    249249                }else{
    250                     throw new Exception(__('No order found','wpos-lite'));
     250                    throw new Exception(__('No order found','openpos'));
    251251                }
    252252               
     
    289289                    $result['response']['status'] = 1;
    290290                }else{
    291                     throw new Exception(__('Order not found.','wpos-lite'));
     291                    throw new Exception(__('Order not found.','openpos'));
    292292                }
    293293                $result['code'] = 200;
     
    315315                if(!$order_number)
    316316                {
    317                     throw new Exception(__('Order number is required','wpos-lite'));
     317                    throw new Exception(__('Order number is required','openpos'));
    318318                }
    319319                $order_id = $this->order_class->get_order_id_from_number($order_number);
    320320                if(!$order_id)
    321321                {
    322                     throw new Exception(__('Order not found','wpos-lite'));
     322                    throw new Exception(__('Order not found','openpos'));
    323323                }
    324324                $order = wc_get_order($order_id);
    325325                if(!$order)
    326326                {
    327                     throw new Exception(__('Order not found','wpos-lite'));
     327                    throw new Exception(__('Order not found','openpos'));
    328328                }
    329329               
     
    331331                if(!$formatted_order || empty($formatted_order))
    332332                {
    333                     throw new Exception(__('Order not found','wpos-lite'));
     333                    throw new Exception(__('Order not found','openpos'));
    334334                }
    335335                $result['data']['result'] = $formatted_order;
     
    360360                if(!$local_id)
    361361                {
    362                     throw new Exception(__('Local ID is required','wpos-lite'));
     362                    throw new Exception(__('Local ID is required','openpos'));
    363363                }
    364364                $order_id = $this->order_class->get_order_id_from_local_id($local_id);
     
    366366                if(!$order_id)
    367367                {
    368                     throw new Exception(__('Order not found','wpos-lite'));
     368                    throw new Exception(__('Order not found','openpos'));
    369369                }
    370370                $order = wc_get_order($order_id);
    371371                if(!$order)
    372372                {
    373                     throw new Exception(__('Order not found','wpos-lite'));
     373                    throw new Exception(__('Order not found','openpos'));
    374374                }
    375375               
     
    377377                if(!$formatted_order || empty($formatted_order))
    378378                {
    379                     throw new Exception(__('Order not found','wpos-lite'));
     379                    throw new Exception(__('Order not found','openpos'));
    380380                }
    381381               
     
    447447                if(!$order_id)
    448448                {
    449                     throw new Exception(__('Order Id is required','wpos-lite'));
     449                    throw new Exception(__('Order Id is required','openpos'));
    450450                }
    451451               
     
    462462                if(!$order)
    463463                {
    464                     throw new Exception(__('Order not found','wpos-lite'));
     464                    throw new Exception(__('Order not found','openpos'));
    465465                }
    466466                $notes = $this->order_class->getOrderNotes($order->get_id());
     
    493493                $login_cashdrawer_id = isset($session_data['login_cashdrawer_id']) ? $session_data['login_cashdrawer_id'] : 0;
    494494                $order_parse_data = apply_filters('op_new_order_data',$order_data,$session_data);
     495
     496               
     497
    495498                $order = $this->order_class->add_order($order_parse_data,$session_data,$is_clear,$order_source);
    496499
     
    510513                            $transaction_data = apply_filters('op_order_transaction_data',$transaction,$order,$order_parse_data);
    511514                            $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;
    512517                            if($transaction_id)
    513518                            {
    514                                 $transient_key = 'adding_transaction_'.$transaction_id;
     519                               
    515520                                $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 ) {
    517525                                    $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data);
    518526                                    $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0;
     
    548556                                   
    549557                                    }
    550                                     delete_transient( $transient_key );
     558                                   
    551559                                    //end
    552560                                    if($id)
     
    565573                                            }
    566574                                        }
     575                                        set_transient( $done_transient_key, $id, DAY_IN_SECONDS );
    567576                                        if($is_new)
    568577                                        {
     
    570579                                        }
    571580                                    }
     581                                    delete_transient( $transient_key );
    572582                                }
    573583                            }
     
    624634                    $result['status'] = 1;
    625635                    $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']);
    627637                }else{
    628                     throw new Exception(__('Can not create order.','wpos-lite'));
     638                    throw new Exception(__('Can not create order.','openpos'));
    629639                }
    630640               
     
    702712                if(!$order_id)
    703713                {
    704                     throw new Exception(__('Order Id is required','wpos-lite'));
     714                    throw new Exception(__('Order Id is required','openpos'));
    705715                }
    706716                $order = wc_get_order($order_id);
     
    934944                                {
    935945                                    $fee_item = new WC_Order_Item_Fee();
    936                                     $fee_item->set_name(__('Exchange Fee','wpos-lite'));
     946                                    $fee_item->set_name(__('Exchange Fee','openpos'));
    937947                                    $fee_item->set_total($_exchange['fee_amount']);
    938948                                    $fee_item->set_amount($_exchange['fee_amount']);
     
    943953                                {
    944954                                    $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'));
    946956                                    $fee_item->set_total($addition_total);
    947957                                    $fee_item->set_amount($addition_total);
     
    12601270                        $result['response']['status'] = 1;
    12611271                    }else{
    1262                         throw new Exception(__('Order is not found', 'wpos-lite'));
     1272                        throw new Exception(__('Order is not found', 'openpos'));
    12631273                    }
    12641274
     
    12671277
    12681278                }else{
    1269                     throw new Exception( __('Order number too short','wpos-lite') );
     1279                    throw new Exception( __('Order number too short','openpos') );
    12701280
    12711281                }
     
    13311341                    do_action('op_save_order_note_after',$order_note,$order_status,$order);
    13321342                }else{
    1333                     throw new Exception(__('Order not found.','wpos-lite'));
     1343                    throw new Exception(__('Order not found.','openpos'));
    13341344                }
    13351345                $result['code'] = 200;
     
    13651375                    $result['response'] = $this->receipt_class->send_receipt($send_to,$order_data,$register_id,'manual');
    13661376                }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');
    13681378                }
    13691379            }catch(Exception $e)
     
    14141424                        $result['response']['data'] = $this->woo_class->formatWooOrder($order->get_id());
    14151425                    }else{
    1416                         throw new Exception(__('Order is not found','wpos-lite'));
     1426                        throw new Exception(__('Order is not found','openpos'));
    14171427                    }
    14181428                }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'));
    14201430                }
    14211431            }catch(Exception $e)
     
    14431453                if(!$customer_id)
    14441454                {
    1445                     throw new Exception(__('Customer do not exist','wpos-lite'));
     1455                    throw new Exception(__('Customer do not exist','openpos'));
    14461456                }
    14471457                $customer = new WC_Customer($customer_id);
    14481458                if(!$customer)
    14491459                {
    1450                     throw new Exception(__('Customer do not exist','wpos-lite'));
     1460                    throw new Exception(__('Customer do not exist','openpos'));
    14511461                }
    14521462                $total_order_count = $customer->get_order_count();
     
    15801590                                //$pos_order->close_order();
    15811591                            }
    1582                             $pos_order->update_status($status ,__('Closed from POS','wpos-lite'));
     1592                            $pos_order->update_status($status ,__('Closed from POS','openpos'));
    15831593
    15841594                            $result['response']['status'] = 1;
    15851595                        }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');
    15871597
    15881598                        }
     
    15901600                       
    15911601                    }else{
    1592                         throw new Exception( __('Order is not found', 'wpos-lite'));
     1602                        throw new Exception( __('Order is not found', 'openpos'));
    15931603                    }
    15941604
    15951605                }else{
    1596                     throw new Exception(__('Order is not found', 'wpos-lite'));
     1606                    throw new Exception(__('Order is not found', 'openpos'));
    15971607
    15981608                }
     
    16391649                        $result['response']['data'] = $formatted_order;
    16401650                        $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;
    16421652                        $result['response']['status'] = 1;
    16431653                    }else{
    1644                         throw new Exception( __('Order is not found','wpos-lite') );
     1654                        throw new Exception( __('Order is not found','openpos') );
    16451655                    }
    16461656
     
    16491659
    16501660                }else{
    1651                     throw new Exception(__('Order number too short','wpos-lite'));
     1661                    throw new Exception(__('Order number too short','openpos'));
    16521662
    16531663                }
     
    17171727                                //$pos_order->close_order();
    17181728                            }
    1719                             $pos_order->update_status($status ,__('Closed from POS','wpos-lite'));
     1729                            $pos_order->update_status($status ,__('Closed from POS','openpos'));
    17201730
    17211731                            $result['response']['status'] = 1;
    17221732                        }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');
    17241734
    17251735                        }
     
    17271737                       
    17281738                    }else{
    1729                         throw new Exception( __('Order is not found', 'wpos-lite'));
     1739                        throw new Exception( __('Order is not found', 'openpos'));
    17301740                    }
    17311741
     
    17341744
    17351745                }else{
    1736                     throw new Exception(__('Order is not found', 'wpos-lite'));
     1746                    throw new Exception(__('Order is not found', 'openpos'));
    17371747
    17381748                }
  • wpos-lite-version/tags/3.0/includes/api/Product.php

    r3373005 r3376736  
    5252        private function _formatApiProduct($product_data,$session_data){
    5353            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;
    55111        }
    56112        public function products($request)
     
    72128                    $term = sanitize_text_field($term);
    73129                }
    74                 $per_page = $request->get_param( 'per_page' );
     130                $per_page = $request->get_param( 'per_page' ) ;
    75131                $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);
    77133                $current = $page;
    78134                $offet = ($current -1) * $rowCount;
     
    105161                $data = array('total_page' => $total_page, 'current_page' => $current,'term'=>$term);
    106162       
    107                 $data['product'] = array();
     163                $data['products'] = array();
    108164               
    109165                $show_out_of_stock = false;
     
    188244                $login_warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0;
    189245                $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;
    190248                $database_version = get_option('_openpos_product_version_'.$login_warehouse_id,0);
    191249                if($local_db_version > 0)
    192250                {
    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;
    196252                   
     253                    $product_changed_data = $this->woo_class->getProductChanged($local_db_version,$login_warehouse_id,$page,$per_page);
     254
    197255                    $product_ids = array();
    198256                    foreach($product_changed_data['data'] as $product_id => $qty)
     
    203261                    $data = array('total_page' => 0,'page' => 0,'version' => $product_changed_data['current_version']);
    204262
    205                    
    206263                    $data['product'] = array();
    207264                    $data['delete_product'] = array();
     
    253310                    }
    254311                    $version = $product_changed_data['current_version'];
    255                
     312                    $found_posts = $product_changed_data['found_posts'];
     313                   
     314                    $next_page = 1;
    256315                    if(empty($data['product']) &&  $version == 0)
    257316                    {
    258317                        $version = $database_version;
     318                    }else{
     319                        if($version == $local_db_version)
     320                        {
     321                            $next_page = 1 + $page;
     322                        }
    259323                    }
    260324
    261325                    $result['response']['data'] = array(
    262326                        'products' => $data['product'],
    263                         'version' => 1*$version
     327                        'next_page' => $next_page,
     328                        'version' => $version
    264329                    );
    265330                }else{
    266331                    $result['response']['data'] = array(
    267332                        'products' => array(),
    268                         'version' => 1*$database_version
     333                        'version' => $database_version
    269334                    );
    270335                }
     
    311376                if(!$barcode)
    312377                {
    313                     throw new Exception(__('Please enter product barcode','wpos-lite'));
     378                    throw new Exception(__('Please enter product barcode','openpos'));
    314379                }
    315380                $product_id = $this->core_class->getProductIdByBarcode($barcode);
     
    365430                {
    366431   
    367                     throw new Exception(__('Please enter term to search','wpos-lite'));
     432                    throw new Exception(__('Please enter term to search','openpos'));
    368433                }
    369434                $product_id = $this->core_class->getProductIdByBarcode($term);
     
    438503                    $result['code'] = 200;
    439504                    $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');
    441506                }else{
    442507                    $result['code'] = 200;
     
    468533                {
    469534   
    470                     throw new Exception(__('Please enter term to search','wpos-lite'));
     535                    throw new Exception(__('Please enter term to search','openpos'));
    471536                }
    472537                $session_data = $this->session_data;
     
    552617                if(!$term)
    553618                {
    554                     throw new Exception(__('Please enter barcode to scan','wpos-lite'));
     619                    throw new Exception(__('Please enter barcode to scan','openpos'));
    555620                }
    556621                $session_data = $this->session_data;
     
    578643                    }else{
    579644                        $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);
    581646                    }
    582647                    $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  
    4646                if(!$register_id)
    4747                {
    48                     throw new Exception(__('Register not found','wpos-lite'));
     48                    throw new Exception(__('Register not found','openpos'));
    4949                }
    5050                $order_id_old = $request->get_param('order_id');
     
    128128                        $result['response']['status'] = 1;
    129129                    }else{
    130                         throw new Exception(__('Order not found.','wpos-lite'));
     130                        throw new Exception(__('Order not found.','openpos'));
    131131                    }
    132132                   
     
    157157               
    158158                $transaction_id =  isset($transaction['id']) ? $transaction['id'] : 0;
     159                $transient_key = 'adding_transaction_'.$transaction_id;
     160                $done_transient_key = 'done_transaction_'.$transaction_id;
    159161                if($transaction_id)
    160162                {
    161                     $transient_key = 'adding_transaction_'.$transaction_id;
     163                   
     164                    $done_transaction_data = get_transient($done_transient_key);
    162165                    $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);
    169222           
    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)
    211230                            {
    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);
    217232                            }
    218233                        }
    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                   
    227237
    228238                }
     
    250260                if(!$transaction_id)
    251261                {
    252                     throw new Exception(__('Transaction ID is required','wpos-lite'));
     262                    throw new Exception(__('Transaction ID is required','openpos'));
    253263                }
    254264                $register = isset($this->session_data['register']) ? $this->session_data['register'] : [];
    255265                if(!isset($register['id']))
    256266                {
    257                     throw new Exception(__('Register not found','wpos-lite'));
     267                    throw new Exception(__('Register not found','openpos'));
    258268                }
    259269                $warehouse_id = $register['outlet_id'];
     
    261271                if(!$transaction)
    262272                {
    263                     throw new Exception(__('Transaction not found','wpos-lite'));
     273                    throw new Exception(__('Transaction not found','openpos'));
    264274                }
    265275                $result['data']['result'] = $transaction;
     
    307317                {
    308318                   
    309                     throw new Exception(__('Order not found','wpos-lite'));
     319                    throw new Exception(__('Order not found','openpos'));
    310320                }
    311321                $transaction_id =  isset($transaction['id']) ? $transaction['id'] : 0;
     
    364374                           
    365375                            $_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'));
    367377                           
    368378                        }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']);
    370380                            $this->order_class->addOrderNote($order_id,$note);
    371381                        }
     
    377387                        );
    378388                    }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));
    380390                    }
    381391               
    382392                }else{
    383                     throw new Exception(__('Amount value is incorrect','wpos-lite'));
     393                    throw new Exception(__('Amount value is incorrect','openpos'));
    384394                }
    385395                $result['code'] = 200;
  • wpos-lite-version/trunk/includes/Core.php

    r3373027 r3376736  
    4848        //language
    4949            $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/' );
    5353        //end
    5454    }
     
    104104    }
    105105    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');
    107107        return $this->plugin_info;
    108108    }
     
    13101310            if( $diff_month > 12 || $diff_day < 0)
    13111311            {
    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'));
    13131313            }
    13141314        }
     
    14341434            $show_date = sprintf(
    14351435            /* 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' ),
    14371437                human_time_diff( $order_object->get_date_created()->getTimestamp(), current_time( 'timestamp', true ) )
    14381438            );
    14391439        } 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' ) ) );
    14411441        }
    14421442        return sprintf(
     
    14571457            $show_date = sprintf(
    14581458            /* 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' ),
    14601460                human_time_diff( $order_timestamp, current_time( 'timestamp', true ) )
    14611461            );
    14621462        } 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' ) ) );
    14641464        }
    14651465        return sprintf(
     
    14851485        $payment_options['chip_pin'] = array(
    14861486           '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'),
    14891489            'description' => ''
    14901490        );
     
    14921492        // $payment_options['stripe'] = array(
    14931493        //     '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'),
    14961496        //     'description' => ''
    14971497        // );
     
    15601560                if($code == 'chip_pin')
    15611561                {
    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');
    15631563                    $allow_refund = 'offline';
    15641564                }
     
    15801580    function getAllLanguage(){
    15811581        $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"),
    17751771        );
    17761772        sort($langs);
     
    17781774            '_auto' => 'Auto Detect'
    17791775        );
    1780         foreach($langs as $lang)
    1781         {
    1782             $result[$lang] = $lang;
     1776        foreach($langs as $lang_code => $lang)
     1777        {
     1778            $result[$lang_code] = $lang;
    17831779        }
    17841780
     
    18161812    public function formatReceiptSetting($setting,$op_incl_tax_mode= false)
    18171813    {
    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       
    18421815
    18431816        //receipt css
     
    18601833        if(isset($setting['receipt_template_footer']))
    18611834        {
    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']);
    18631836        }else{
    18641837            $setting['receipt_template_footer'] = '';
     
    18741847        if(isset($setting['receipt_template_header']))
    18751848        {
    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']);
    18771850        }else{
    18781851            $setting['receipt_template_header'] = '';
     
    18831856
    18841857
    1885         $file_path = rtrim(WPOSL_DIR,'/').'/default/'.$file_name;
     1858        $file_path = rtrim(OPENPOS_DIR,'/').'/default/'.$file_name;
    18861859
    18871860        $theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$file_name;
     
    18931866            {
    18941867                $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;
    18961869            }
    18971870        }
    18981871        $_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;
    19001873
    19011874        $gift_theme_file_path = rtrim(get_stylesheet_directory(),'/').'/woocommerce-openpos/'.$_gift_file_name;
     
    19181891            $receipt_template = '<table>
    19191892            <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>
    19251898            </tr>
    19261899            <% items.forEach(function(item){ %>
     
    19431916            <tr class="tabletitle">
    19441917                <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>
    19461919                <td class="payment sub-total-amount"><h2><%= sub_total %></h2></td>
    19471920            </tr>
     
    19491922            <tr class="tabletitle">
    19501923                <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>
    19521925                <td class="payment shipping-amount"><h2><%= shipping_cost %></h2></td>
    19531926            </tr>
     
    19551928            <tr class="tabletitle">
    19561929                <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>
    19581931                <td class="payment cart-discount-amount"><h2><%= final_discount_amount %></h2></td>
    19591932            </tr>
    19601933            <tr class="tabletitle">
    19611934                <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>
    19631936                <td class="payment tax-amount"><h2><%= tax_amount %></h2></td>
    19641937            </tr>
    19651938            <tr class="tabletitle">
    19661939                <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>
    19681941                <td class="payment grand-total-amount"><h2><%= grand_total %></h2></td>
    19691942            </tr>
     
    20542027        if($timezone)
    20552028        {
     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();
    20562033            return get_date_from_gmt($time_str,'d-m-Y H:i:s');
    20572034        }else{
     
    20622039    public function getReceiptFontCss(){
    20632040        $font_css = array();
    2064         $font_css['receipt_font'] = WPOSL_URL.'/pos/font.css';
     2041        $font_css['receipt_font'] = OPENPOS_URL.'/pos/font.css';
    20652042        return $font_css;
    20662043    }
     
    21842161    function get_pos_url($sub_str = ''){
    21852162     
    2186         $pos_url = apply_filters('op_pos_url','https://pos.wpos.app');
     2163        $pos_url = apply_filters('op_pos_url',OPENPOS_URL.'/pos/');
    21872164        if($sub_str)
    21882165        {
     
    21922169        }
    21932170        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;
    21942218    }
    21952219    function get_hosting_time($local_time,$client_time_offset = 0){ // in min
     
    22152239   
    22162240    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 );
    22182259        if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
    22192260           $this->_enable_hpos = true;
     
    22222263    }
    22232264    function getTemplatePath($file_name){
    2224         $templath_dir = 'wpos-lite-version/';
     2265        #$templath_path = OPENPOS_DIR.'templates/emails/';
     2266        $templath_dir = 'woocommerce-openpos/';
    22252267        $check_dirs = array(
    22262268            trailingslashit( get_stylesheet_directory() ) . $templath_dir,
     
    22282270            trailingslashit( get_stylesheet_directory() ),
    22292271            trailingslashit( get_template_directory() ),
    2230             trailingslashit( WPOSL_DIR ) . 'templates/',
     2272            trailingslashit( OPENPOS_DIR ) . 'templates/',
    22312273        );
    22322274        foreach ( $check_dirs as $dir ) {
     
    24882530    }
    24892531
     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    }
    24902547   
    2491    
    24922548
    24932549}
  • wpos-lite-version/trunk/includes/api/Api.php

    r3372360 r3376736  
    7878           
    7979            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));
    8181            }
    8282            return true;
    8383        }
     84       
    8485        protected function check_auth_header(WP_REST_Request $request) {
    8586            $session_id = $request->get_param('session', '');
     
    8788            {
    8889                $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                }
    8996                if($session_data)
    9097                {
     
    138145            return floor($number);
    139146        }
     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        }
    140170       
    141171
  • wpos-lite-version/trunk/includes/api/Auth.php

    r3373027 r3376736  
    6262                array(
    6363                    'id'    => 'openpos_general',
    64                     'title' => __( 'General', 'wpos-lite')
     64                    'title' => __( 'General', 'openpos' )
    6565                ),
    6666                array(
    6767                    'id'    => 'openpos_payment',
    68                     'title' => __( 'Payment', 'wpos-lite')
     68                    'title' => __( 'Payment', 'openpos' )
    6969                ),
    7070                array(
    7171                    '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' )
    7381                ),
    7482                array(
    7583                    'id'    => 'openpos_pos',
    76                     'title' => __( 'POS Layout', 'wpos-lite')
     84                    'title' => __( 'POS Layout', 'openpos' )
    7785                )
    7886            );
    7987           
    80            
    81             $ignore = array();
    8288            $setting = array();
     89            $ignore = array(
     90                'stripe_public_key',
     91                'stripe_secret_key'
     92            );
     93           
    8394            foreach($setting_sections as $section)
    8495            {
     
    174185           
    175186            }
    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            }
    275198
    276199            $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);
    279202           
    280203            return $setting;
     
    293216           
    294217            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                }
    295222                $username = $request->get_param( 'username' );
    296223                $password = $request->get_param( 'password' );
     
    340267                if(!$allow_pos)
    341268                {
    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' ));
    343270                }
    344271
    345272                if(!$drawers || empty($drawers))
    346273                {
    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' ));
    348275                }
    349276                $ip = $this->core_class->getClientIp();
     
    355282                }
    356283               
    357                 $avatar = rtrim(WPOSL_URL,'/').'/assets/images/default_avatar.png';
     284                $avatar = rtrim(OPENPOS_URL,'/').'/assets/images/default_avatar.png';
    358285
    359286                $avatar_args = get_avatar_data( $id);
     
    473400                $session_data['currency_decimal'] = wc_get_price_decimals() ;
    474401
    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 ;
    476416                $session_data['product_sync'] = true;
    477417                $session_data['date_format'] = $this->core_class->convert_to_js_date_format(get_option( 'date_format' ));
     
    582522                $session_data['role'] = $roles;
    583523                //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               
    596525
    597526                $setting['currencies'] = $availble_currencies;
     
    686615                    if( !$password)
    687616                    {
    688                         throw new Exception(__('PIN can not empty.','wpos-lite'));
     617                        throw new Exception(__('PIN can not empty.','openpos' ));
    689618                    }
    690619                    $user = $this->woo_class->pin_authenticate($password,false);
     
    705634                        $result['response']['status'] = 1;
    706635                    }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' ));
    708637                    }
    709638
     
    713642                    if(!$password)
    714643                    {
    715                         throw new Exception(__('Please enter password','wpos-lite'));
     644                        throw new Exception(__('Please enter password','openpos' ));
    716645                    }
    717646                   
    718647                    $user = wp_authenticate($username, $password);
    719648                    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' ));
    721650                    }
    722651                    $result['response']['data'] = array('logon_user_id' => $user->ID,'session_data' =>$session_data);
     
    772701                if(empty($session_data))
    773702                {
    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'));
    775704                }
    776705                $check = true;
     
    783712                    $result['response']['status'] = 0;
    784713                    $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');
    786715                }
    787716                $result['code'] = 200;
     
    884813                if($this->setting_class->get_option('openpos_type','openpos_pos') == 'restaurant' )
    885814                {
    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();
    887816                   
    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)
    893822                        {
    894823                            $source_type = isset($table['source_type']) ? $table['source_type'] : '';
     
    898827                            }
    899828                        }
    900                     }
    901 
    902                     //save to table data
    903                     //disable auto background save item on table
    904                     if(!empty($tables))
    905                     {
    906829                        $this->table_class->update_bill_screen($tables,true);
    907830                    }
    908                    
    909831
    910832                    $warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0;
     
    921843                    if(!empty($tables_desk_messages))
    922844                    {
    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));
    924846                       
    925847                    }
     
    960882                $result['response']['data'] = array(
    961883                    'version' => $this->core_class->_op_version_number(),
    962                     'type' => 'wpos-lite-version',
     884                    'type' => 'woocommerce-openpos',
    963885                    'woo_version' => WC()->version,
    964886                    'wp_version' => get_bloginfo( 'version' ),
  • wpos-lite-version/trunk/includes/api/Order.php

    r3372360 r3376736  
    248248                    $result['response']['status'] = 1;
    249249                }else{
    250                     throw new Exception(__('No order found','wpos-lite'));
     250                    throw new Exception(__('No order found','openpos'));
    251251                }
    252252               
     
    289289                    $result['response']['status'] = 1;
    290290                }else{
    291                     throw new Exception(__('Order not found.','wpos-lite'));
     291                    throw new Exception(__('Order not found.','openpos'));
    292292                }
    293293                $result['code'] = 200;
     
    315315                if(!$order_number)
    316316                {
    317                     throw new Exception(__('Order number is required','wpos-lite'));
     317                    throw new Exception(__('Order number is required','openpos'));
    318318                }
    319319                $order_id = $this->order_class->get_order_id_from_number($order_number);
    320320                if(!$order_id)
    321321                {
    322                     throw new Exception(__('Order not found','wpos-lite'));
     322                    throw new Exception(__('Order not found','openpos'));
    323323                }
    324324                $order = wc_get_order($order_id);
    325325                if(!$order)
    326326                {
    327                     throw new Exception(__('Order not found','wpos-lite'));
     327                    throw new Exception(__('Order not found','openpos'));
    328328                }
    329329               
     
    331331                if(!$formatted_order || empty($formatted_order))
    332332                {
    333                     throw new Exception(__('Order not found','wpos-lite'));
     333                    throw new Exception(__('Order not found','openpos'));
    334334                }
    335335                $result['data']['result'] = $formatted_order;
     
    360360                if(!$local_id)
    361361                {
    362                     throw new Exception(__('Local ID is required','wpos-lite'));
     362                    throw new Exception(__('Local ID is required','openpos'));
    363363                }
    364364                $order_id = $this->order_class->get_order_id_from_local_id($local_id);
     
    366366                if(!$order_id)
    367367                {
    368                     throw new Exception(__('Order not found','wpos-lite'));
     368                    throw new Exception(__('Order not found','openpos'));
    369369                }
    370370                $order = wc_get_order($order_id);
    371371                if(!$order)
    372372                {
    373                     throw new Exception(__('Order not found','wpos-lite'));
     373                    throw new Exception(__('Order not found','openpos'));
    374374                }
    375375               
     
    377377                if(!$formatted_order || empty($formatted_order))
    378378                {
    379                     throw new Exception(__('Order not found','wpos-lite'));
     379                    throw new Exception(__('Order not found','openpos'));
    380380                }
    381381               
     
    447447                if(!$order_id)
    448448                {
    449                     throw new Exception(__('Order Id is required','wpos-lite'));
     449                    throw new Exception(__('Order Id is required','openpos'));
    450450                }
    451451               
     
    462462                if(!$order)
    463463                {
    464                     throw new Exception(__('Order not found','wpos-lite'));
     464                    throw new Exception(__('Order not found','openpos'));
    465465                }
    466466                $notes = $this->order_class->getOrderNotes($order->get_id());
     
    493493                $login_cashdrawer_id = isset($session_data['login_cashdrawer_id']) ? $session_data['login_cashdrawer_id'] : 0;
    494494                $order_parse_data = apply_filters('op_new_order_data',$order_data,$session_data);
     495
     496               
     497
    495498                $order = $this->order_class->add_order($order_parse_data,$session_data,$is_clear,$order_source);
    496499
     
    510513                            $transaction_data = apply_filters('op_order_transaction_data',$transaction,$order,$order_parse_data);
    511514                            $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;
    512517                            if($transaction_id)
    513518                            {
    514                                 $transient_key = 'adding_transaction_'.$transaction_id;
     519                               
    515520                                $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 ) {
    517525                                    $transaction_data = $this->transaction_class->formatDataFromJson($transaction,$session_data);
    518526                                    $in_amount = isset($transaction_data['in_amount']) ? floatval($transaction_data['in_amount']) : 0;
     
    548556                                   
    549557                                    }
    550                                     delete_transient( $transient_key );
     558                                   
    551559                                    //end
    552560                                    if($id)
     
    565573                                            }
    566574                                        }
     575                                        set_transient( $done_transient_key, $id, DAY_IN_SECONDS );
    567576                                        if($is_new)
    568577                                        {
     
    570579                                        }
    571580                                    }
     581                                    delete_transient( $transient_key );
    572582                                }
    573583                            }
     
    624634                    $result['status'] = 1;
    625635                    $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']);
    627637                }else{
    628                     throw new Exception(__('Can not create order.','wpos-lite'));
     638                    throw new Exception(__('Can not create order.','openpos'));
    629639                }
    630640               
     
    702712                if(!$order_id)
    703713                {
    704                     throw new Exception(__('Order Id is required','wpos-lite'));
     714                    throw new Exception(__('Order Id is required','openpos'));
    705715                }
    706716                $order = wc_get_order($order_id);
     
    934944                                {
    935945                                    $fee_item = new WC_Order_Item_Fee();
    936                                     $fee_item->set_name(__('Exchange Fee','wpos-lite'));
     946                                    $fee_item->set_name(__('Exchange Fee','openpos'));
    937947                                    $fee_item->set_total($_exchange['fee_amount']);
    938948                                    $fee_item->set_amount($_exchange['fee_amount']);
     
    943953                                {
    944954                                    $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'));
    946956                                    $fee_item->set_total($addition_total);
    947957                                    $fee_item->set_amount($addition_total);
     
    12601270                        $result['response']['status'] = 1;
    12611271                    }else{
    1262                         throw new Exception(__('Order is not found', 'wpos-lite'));
     1272                        throw new Exception(__('Order is not found', 'openpos'));
    12631273                    }
    12641274
     
    12671277
    12681278                }else{
    1269                     throw new Exception( __('Order number too short','wpos-lite') );
     1279                    throw new Exception( __('Order number too short','openpos') );
    12701280
    12711281                }
     
    13311341                    do_action('op_save_order_note_after',$order_note,$order_status,$order);
    13321342                }else{
    1333                     throw new Exception(__('Order not found.','wpos-lite'));
     1343                    throw new Exception(__('Order not found.','openpos'));
    13341344                }
    13351345                $result['code'] = 200;
     
    13651375                    $result['response'] = $this->receipt_class->send_receipt($send_to,$order_data,$register_id,'manual');
    13661376                }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');
    13681378                }
    13691379            }catch(Exception $e)
     
    14141424                        $result['response']['data'] = $this->woo_class->formatWooOrder($order->get_id());
    14151425                    }else{
    1416                         throw new Exception(__('Order is not found','wpos-lite'));
     1426                        throw new Exception(__('Order is not found','openpos'));
    14171427                    }
    14181428                }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'));
    14201430                }
    14211431            }catch(Exception $e)
     
    14431453                if(!$customer_id)
    14441454                {
    1445                     throw new Exception(__('Customer do not exist','wpos-lite'));
     1455                    throw new Exception(__('Customer do not exist','openpos'));
    14461456                }
    14471457                $customer = new WC_Customer($customer_id);
    14481458                if(!$customer)
    14491459                {
    1450                     throw new Exception(__('Customer do not exist','wpos-lite'));
     1460                    throw new Exception(__('Customer do not exist','openpos'));
    14511461                }
    14521462                $total_order_count = $customer->get_order_count();
     
    15801590                                //$pos_order->close_order();
    15811591                            }
    1582                             $pos_order->update_status($status ,__('Closed from POS','wpos-lite'));
     1592                            $pos_order->update_status($status ,__('Closed from POS','openpos'));
    15831593
    15841594                            $result['response']['status'] = 1;
    15851595                        }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');
    15871597
    15881598                        }
     
    15901600                       
    15911601                    }else{
    1592                         throw new Exception( __('Order is not found', 'wpos-lite'));
     1602                        throw new Exception( __('Order is not found', 'openpos'));
    15931603                    }
    15941604
    15951605                }else{
    1596                     throw new Exception(__('Order is not found', 'wpos-lite'));
     1606                    throw new Exception(__('Order is not found', 'openpos'));
    15971607
    15981608                }
     
    16391649                        $result['response']['data'] = $formatted_order;
    16401650                        $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;
    16421652                        $result['response']['status'] = 1;
    16431653                    }else{
    1644                         throw new Exception( __('Order is not found','wpos-lite') );
     1654                        throw new Exception( __('Order is not found','openpos') );
    16451655                    }
    16461656
     
    16491659
    16501660                }else{
    1651                     throw new Exception(__('Order number too short','wpos-lite'));
     1661                    throw new Exception(__('Order number too short','openpos'));
    16521662
    16531663                }
     
    17171727                                //$pos_order->close_order();
    17181728                            }
    1719                             $pos_order->update_status($status ,__('Closed from POS','wpos-lite'));
     1729                            $pos_order->update_status($status ,__('Closed from POS','openpos'));
    17201730
    17211731                            $result['response']['status'] = 1;
    17221732                        }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');
    17241734
    17251735                        }
     
    17271737                       
    17281738                    }else{
    1729                         throw new Exception( __('Order is not found', 'wpos-lite'));
     1739                        throw new Exception( __('Order is not found', 'openpos'));
    17301740                    }
    17311741
     
    17341744
    17351745                }else{
    1736                     throw new Exception(__('Order is not found', 'wpos-lite'));
     1746                    throw new Exception(__('Order is not found', 'openpos'));
    17371747
    17381748                }
  • wpos-lite-version/trunk/includes/api/Product.php

    r3373004 r3376736  
    5252        private function _formatApiProduct($product_data,$session_data){
    5353            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;
    55111        }
    56112        public function products($request)
     
    72128                    $term = sanitize_text_field($term);
    73129                }
    74                 $per_page = $request->get_param( 'per_page' );
     130                $per_page = $request->get_param( 'per_page' ) ;
    75131                $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);
    77133                $current = $page;
    78134                $offet = ($current -1) * $rowCount;
     
    105161                $data = array('total_page' => $total_page, 'current_page' => $current,'term'=>$term);
    106162       
    107                 $data['product'] = array();
     163                $data['products'] = array();
    108164               
    109165                $show_out_of_stock = false;
     
    188244                $login_warehouse_id = isset($session_data['login_warehouse_id']) ? $session_data['login_warehouse_id'] : 0;
    189245                $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;
    190248                $database_version = get_option('_openpos_product_version_'.$login_warehouse_id,0);
    191249                if($local_db_version > 0)
    192250                {
    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;
    196252                   
     253                    $product_changed_data = $this->woo_class->getProductChanged($local_db_version,$login_warehouse_id,$page,$per_page);
     254
    197255                    $product_ids = array();
    198256                    foreach($product_changed_data['data'] as $product_id => $qty)
     
    203261                    $data = array('total_page' => 0,'page' => 0,'version' => $product_changed_data['current_version']);
    204262
    205                    
    206263                    $data['product'] = array();
    207264                    $data['delete_product'] = array();
     
    253310                    }
    254311                    $version = $product_changed_data['current_version'];
    255                
     312                    $found_posts = $product_changed_data['found_posts'];
     313                   
     314                    $next_page = 1;
    256315                    if(empty($data['product']) &&  $version == 0)
    257316                    {
    258317                        $version = $database_version;
     318                    }else{
     319                        if($version == $local_db_version)
     320                        {
     321                            $next_page = 1 + $page;
     322                        }
    259323                    }
    260324
    261325                    $result['response']['data'] = array(
    262326                        'products' => $data['product'],
    263                         'version' => 1*$version
     327                        'next_page' => $next_page,
     328                        'version' => $version
    264329                    );
    265330                }else{
    266331                    $result['response']['data'] = array(
    267332                        'products' => array(),
    268                         'version' => 1*$database_version
     333                        'version' => $database_version
    269334                    );
    270335                }
     
    311376                if(!$barcode)
    312377                {
    313                     throw new Exception(__('Please enter product barcode','wpos-lite'));
     378                    throw new Exception(__('Please enter product barcode','openpos'));
    314379                }
    315380                $product_id = $this->core_class->getProductIdByBarcode($barcode);
     
    365430                {
    366431   
    367                     throw new Exception(__('Please enter term to search','wpos-lite'));
     432                    throw new Exception(__('Please enter term to search','openpos'));
    368433                }
    369434                $product_id = $this->core_class->getProductIdByBarcode($term);
     
    438503                    $result['code'] = 200;
    439504                    $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');
    441506                }else{
    442507                    $result['code'] = 200;
     
    468533                {
    469534   
    470                     throw new Exception(__('Please enter term to search','wpos-lite'));
     535                    throw new Exception(__('Please enter term to search','openpos'));
    471536                }
    472537                $session_data = $this->session_data;
     
    552617                if(!$term)
    553618                {
    554                     throw new Exception(__('Please enter barcode to scan','wpos-lite'));
     619                    throw new Exception(__('Please enter barcode to scan','openpos'));
    555620                }
    556621                $session_data = $this->session_data;
     
    578643                    }else{
    579644                        $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);
    581646                    }
    582647                    $result['response'] = apply_filters('op_get_search_product_result_data',$result['response'],$session_data);
  • wpos-lite-version/trunk/includes/api/Transaction.php

    r3372360 r3376736  
    4646                if(!$register_id)
    4747                {
    48                     throw new Exception(__('Register not found','wpos-lite'));
     48                    throw new Exception(__('Register not found','openpos'));
    4949                }
    5050                $order_id_old = $request->get_param('order_id');
     
    128128                        $result['response']['status'] = 1;
    129129                    }else{
    130                         throw new Exception(__('Order not found.','wpos-lite'));
     130                        throw new Exception(__('Order not found.','openpos'));
    131131                    }
    132132                   
     
    157157               
    158158                $transaction_id =  isset($transaction['id']) ? $transaction['id'] : 0;
     159                $transient_key = 'adding_transaction_'.$transaction_id;
     160                $done_transient_key = 'done_transaction_'.$transaction_id;
    159161                if($transaction_id)
    160162                {
    161                     $transient_key = 'adding_transaction_'.$transaction_id;
     163                   
     164                    $done_transaction_data = get_transient($done_transient_key);
    162165                    $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);
    169222           
    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)
    211230                            {
    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);
    217232                            }
    218233                        }
    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                   
    227237
    228238                }
     
    250260                if(!$transaction_id)
    251261                {
    252                     throw new Exception(__('Transaction ID is required','wpos-lite'));
     262                    throw new Exception(__('Transaction ID is required','openpos'));
    253263                }
    254264                $register = isset($this->session_data['register']) ? $this->session_data['register'] : [];
    255265                if(!isset($register['id']))
    256266                {
    257                     throw new Exception(__('Register not found','wpos-lite'));
     267                    throw new Exception(__('Register not found','openpos'));
    258268                }
    259269                $warehouse_id = $register['outlet_id'];
     
    261271                if(!$transaction)
    262272                {
    263                     throw new Exception(__('Transaction not found','wpos-lite'));
     273                    throw new Exception(__('Transaction not found','openpos'));
    264274                }
    265275                $result['data']['result'] = $transaction;
     
    307317                {
    308318                   
    309                     throw new Exception(__('Order not found','wpos-lite'));
     319                    throw new Exception(__('Order not found','openpos'));
    310320                }
    311321                $transaction_id =  isset($transaction['id']) ? $transaction['id'] : 0;
     
    364374                           
    365375                            $_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'));
    367377                           
    368378                        }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']);
    370380                            $this->order_class->addOrderNote($order_id,$note);
    371381                        }
     
    377387                        );
    378388                    }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));
    380390                    }
    381391               
    382392                }else{
    383                     throw new Exception(__('Amount value is incorrect','wpos-lite'));
     393                    throw new Exception(__('Amount value is incorrect','openpos'));
    384394                }
    385395                $result['code'] = 200;
Note: See TracChangeset for help on using the changeset viewer.