
















{"id":1246,"date":"2024-02-17T13:40:20","date_gmt":"2024-02-17T06:40:20","guid":{"rendered":"https:\/\/www.nongkhaimaibab.com\/cart\/"},"modified":"2024-11-18T16:01:42","modified_gmt":"2024-11-18T09:01:42","slug":"cart","status":"publish","type":"page","link":"https:\/\/www.nongkhaimaibab.com\/en\/cart\/","title":{"rendered":"\u0e15\u0e30\u0e01\u0e23\u0e49\u0e32\u0e2a\u0e34\u0e19\u0e04\u0e49\u0e32"},"content":{"rendered":"<div data-elementor-type=\"wp-page\" data-elementor-id=\"1246\" class=\"elementor elementor-1246\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-23fb496 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"23fb496\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-no\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c0d5089\" data-id=\"c0d5089\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-64a7328 elementor-widget elementor-widget-shortcode\" data-id=\"64a7328\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<article class=\"\">\n    <div class=\"cart_check\">\n        <div class=\"w-80-center\">\n            <p class=\"font-24px font-w-500\">\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23\u0e2a\u0e34\u0e19\u0e04\u0e49\u0e32<\/p>\n            <table class=\"cart_table\" id=\"tableProductList\">\n            <\/table>\n            <div class=\"total_price\">\n                <p class=\"font-20px font-w-500 p-2 mb-0\">\u0e08\u0e33\u0e19\u0e27\u0e19\u0e23\u0e27\u0e21\u0e17\u0e31\u0e49\u0e07\u0e2a\u0e34\u0e49\u0e19 <span class=\"text-org\" id=\"totalPrice\">0<\/span><\/p>\n            <\/div>\n        <\/div>\n    <\/div>\n    <div class=\"c_info\">\n        <div class=\"w-80-center\">\n            <form action=\"\" class=\"cart_info\" data-trp-original-action=\"\">\n                <p class=\"font-24px font-w-500\">\u0e01\u0e23\u0e38\u0e13\u0e32\u0e23\u0e30\u0e1a\u0e38\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e08\u0e31\u0e14\u0e2a\u0e48\u0e07<\/p>\n                <div class=\"select_type_customer\">\n                    <div class=\"\" id=\"current_customer_select\">\n                        <input type=\"radio\" id=\"\" name=\"customer\" value=\"\" onclick=\"current_customer()\">\n                        <label for=\"\">\u0e25\u0e39\u0e01\u0e04\u0e49\u0e32\u0e40\u0e01\u0e48\u0e32<\/label>\n                    <\/div>\n                    <div class=\"active\" id=\"new_customer_select\">\n                        <input type=\"radio\" id=\"\" name=\"customer\" value=\"\" onclick=\"new_customer()\" checked>\n                        <label for=\"\">\u0e25\u0e39\u0e01\u0e04\u0e49\u0e32\u0e43\u0e2b\u0e21\u0e48<\/label>\n                    <\/div>\n                <\/div>\n                \n                <div class=\"cart_info_grid\">\n                    <div class=\"current_customer\" id=\"current_customer\">\n                        <label for=\"tel\" class=\"d-block\">\u0e40\u0e1a\u0e2d\u0e23\u0e4c\u0e42\u0e17\u0e23\u0e28\u0e31\u0e1e\u0e17\u0e4c<\/label>\n                        <input type=\"tel\" id=\"cs_phone\" name=\"tel\" require>\n                        <br>\n                        <label for=\"loadCustimmer\" class=\"d-block\">\u0e42\u0e1b\u0e23\u0e14\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e0a\u0e37\u0e48\u0e2d\u0e02\u0e2d\u0e07\u0e04\u0e38\u0e13<\/label>\n                        <button type=\"button\" onclick=\"loadCustomer()\" class=\"mb-2\">\u0e04\u0e49\u0e19\u0e2b\u0e32<\/button>\n                        <select id=\"customerlist\" name=\"province\" onclick=\"selectCustomer(event)\" require>\n                        <\/select>\n                    <\/div>\n                    <div class=\"new_customer show-form\"  id=\"new_customer\">\n                        <label for=\"name\" class=\"d-block\">\u0e0a\u0e37\u0e48\u0e2d - \u0e19\u0e32\u0e21\u0e2a\u0e01\u0e38\u0e25 \/ \u0e2d\u0e07\u0e04\u0e4c\u0e01\u0e23 \/ \u0e1a\u0e23\u0e34\u0e29\u0e31\u0e17<\/label>\n                        <input type=\"text\" id=\"name\" name=\"name\" require>\n\n                        <label for=\"tel\" class=\"d-block\">\u0e40\u0e1a\u0e2d\u0e23\u0e4c\u0e42\u0e17\u0e23\u0e28\u0e31\u0e1e\u0e17\u0e4c<\/label>\n                        <input type=\"tel\" id=\"phone\" name=\"tel\" require>\n                        \n                        <label for=\"type\" class=\"d-block\">\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17<\/label>\n                        <select id=\"type\" name=\"type\">\n                            <option value=\"\u0e19\u0e34\u0e15\u0e34\u0e1a\u0e38\u0e04\u0e04\u0e25\">\u0e19\u0e34\u0e15\u0e34\u0e1a\u0e38\u0e04\u0e04\u0e25<\/option>\n                            <option value=\"\u0e1a\u0e38\u0e04\u0e04\u0e25\u0e18\u0e23\u0e23\u0e21\u0e14\u0e32\" selected>\u0e1a\u0e38\u0e04\u0e04\u0e25\u0e18\u0e23\u0e23\u0e21\u0e14\u0e32<\/option>\n                        <\/select>\n\n                        <label for=\"address\" class=\"d-block\">\u0e17\u0e35\u0e48\u0e2d\u0e22\u0e39\u0e48<\/label>\n                        <input type=\"text\" id=\"address\" name=\"address\" require>\n\n                        <label for=\"province_id\" class=\"d-block\">\u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14<\/label>\n                        <select id=\"province_id\" name=\"province\" onclick=\"selectprovince(event)\" require>\n                        <\/select>\n\n                        <label for=\"amphure\" class=\"d-block\">\u0e2d\u0e33\u0e40\u0e20\u0e2d<\/label>\n                        <select id=\"amphure\" name=\"cpt\" onclick=\"selectAmphure(event)\" require>\n                        <\/select>\n\n                        <label for=\"district\" class=\"d-block\">\u0e15\u0e33\u0e1a\u0e25<\/label>\n                        <select id=\"district\" name=\"s_cpt\" onclick=\"selectDistrict(event)\" require>\n                        <\/select>\n                    <\/div>\n                    <div>\n                        <label for=\"shipping_address\" class=\"d-block\">\u0e17\u0e35\u0e48\u0e2d\u0e22\u0e39\u0e48\u0e08\u0e31\u0e14\u0e2a\u0e48\u0e07<\/label>\n                        <input type=\"text\" id=\"oaddress\" name=\"address\" require>\n\n                        <label for=\"oprovince_id\" class=\"d-block\">\u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14<\/label>\n                        <select id=\"oprovince_id\" name=\"province\" onclick=\"oselectprovince(event)\" require>\n                        <\/select>\n\n                        <label for=\"oamphure\" class=\"d-block\">\u0e2d\u0e33\u0e40\u0e20\u0e2d<\/label>\n                        <select id=\"oamphure\" name=\"cpt\" onclick=\"oselectAmphure(event)\" require>\n                        <\/select>\n\n                        <label for=\"odistrict\" class=\"d-block\">\u0e15\u0e33\u0e1a\u0e25<\/label>\n                        <select id=\"odistrict\" name=\"s_cpt\" onclick=\"oselectDistrict(event)\" require>\n                        <\/select>\n                    <\/div>\n                <\/div>\n                <!-- <div class=\"cart_info_grid\">\n                    <div>\n                        <label for=\"tel\" class=\"d-block\">\u0e40\u0e1a\u0e2d\u0e23\u0e4c\u0e42\u0e17\u0e23\u0e28\u0e31\u0e1e\u0e17\u0e4c<\/label>\n                        <input type=\"tel\" id=\"cs_phone\" name=\"tel\" require>\n                        <button type=\"button\" onClick=\"loadCustomer()\">\u0e04\u0e49\u0e19\u0e2b\u0e32<\/button>\n                        \n                        <select id=\"customerlist\" name=\"province\" onClick=\"selectCustomer(event)\" require>\n                        <\/select>\n\n                    <\/div>\n                    <div>\n                        <label for=\"shipping_address\" class=\"d-block\">\u0e17\u0e35\u0e48\u0e2d\u0e22\u0e39\u0e48\u0e08\u0e31\u0e14\u0e2a\u0e48\u0e07<\/label>\n                        <input type=\"text\" id=\"address\" name=\"address\" require>\n\n                        <label for=\"oprovince_id\" class=\"d-block\">\u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14<\/label>\n                        <select id=\"oprovince_id\" name=\"province\" onClick=\"selectprovince(event)\" require>\n                        <\/select>\n\n                        <label for=\"oamphure\" class=\"d-block\">\u0e2d\u0e33\u0e40\u0e20\u0e2d<\/label>\n                        <select id=\"oamphure\" name=\"cpt\" onClick=\"selectAmphure(event)\" require>\n                        <\/select>\n\n                        <label for=\"odistrict\" class=\"d-block\">\u0e15\u0e33\u0e1a\u0e25<\/label>\n                        <select id=\"odistrict\" name=\"s_cpt\" onClick=\"selectDistrict(event)\" require>\n                        <\/select>\n                    <\/div>\n                <\/div> -->\n                <center>\n                    <button type=\"button\" onclick=\"sendOrder()\" class=\"main-bt padding-main-bt cart-bt scale-up font-w-200 text-dark\"> \u0e22\u0e37\u0e19\u0e22\u0e31\u0e19\u0e01\u0e32\u0e23\u0e2a\u0e31\u0e48\u0e07\u0e0b\u0e37\u0e49\u0e2d <\/button>\n                <\/center>\n            <input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form>\n        <\/div>\n    <\/div>\n<\/article>\n\n<script>\n    var ctype = 2;\n    function current_customer() {\n        const box = document.getElementById('current_customer');\n        const box_2 = document.getElementById('new_customer');\n        const box_3 = document.getElementById('current_customer_select');\n        const box_4 = document.getElementById('new_customer_select');\n        \/\/ \u26d4\ufe0f Cannot read properties of null (reading 'classList')\n        box.classList.add('show-form');\n        box_2.classList.remove('show-form');\n        box_3.classList.add('active');\n        box_4.classList.remove('active');\n        ctype = 1;\n        \/\/ document.getElementById(\"sidebar-page\").classList.add(\"show-sidebar\");\n    }\n    function new_customer() {\n        const box = document.getElementById('new_customer');\n        const box_2 = document.getElementById('current_customer');\n        const box_3 = document.getElementById('new_customer_select');\n        const box_4 = document.getElementById('current_customer_select');\n        \/\/ \u26d4\ufe0f Cannot read properties of null (reading 'classList')\n        box.classList.add('show-form');\n        box_2.classList.remove('show-form');\n        box_3.classList.add('active');\n        box_4.classList.remove('active');\n        ctype = 2;\n        \/\/ document.getElementById(\"sidebar-page\").classList.add(\"show-sidebar\");\n    }\n\n\n    var province = [];\n    var customer_id = null;\n    var province_id = null;\n    var amphure = [];\n    var amphure_id = null;\n    var district = [];\n    var district_id = null;\n\n    var oprovince = [];\n    var oprovince_id = null;\n    var oamphure = [];\n    var oamphure_id = null;\n    var odistrict = [];\n    var odistrict_id = null;\n\n    var customerList = [];\n    var products = JSON.parse(localStorage.getItem('carts'));\n    var totalPrice = 0;\n    jQuery(document).ready(function($) {\n        callprovince();\n        products.map((item, index) => {\n            let price = item.sale_type == 'hire' ? item.hire_per_day : item.sale_price;\n            item.qty = item.qty ? item.qty : 1\n            item.total = Number(item.qty) * Number(price);\n        });\n        localStorage.setItem('carts', JSON.stringify(products));\n        \/\/ let products = JSON.parse(localStorage.getItem('carts'));\n        \/\/ console.log(products)\n        loadList();\n       \n    });\n\n    function loadCustomer(){\n\n        let phone = document.getElementById('cs_phone').value\n\n        jQuery(document).ready(function($) {\n            \/\/ AJAX request\n            $.ajax({\n                url: `https:\/\/api.nongkhaimaibab.com\/api\/wordpress\/customerphone?phone=${phone}`,\n                \/\/ url: `https:\/\/7e86-2403-6200-8863-286c-7c03-2ce9-2300-a8b5.ngrok-free.app\/api\/province`,\n                type: 'GET',\n            headers: { \n                'ngrok-skip-browser-warning': 'true',\n            },\n                success: function(response) {\n                    \/\/ Handle the response here\n                    console.log('API response1:', response);\n                    province = response.data;\n\n\n                    var loopDiv = document.getElementById('customerlist');\n                    loopDiv.innerHTML = '';\n                    var elementInstance = '<option value=\"\" disable>-- \u0e01\u0e23\u0e38\u0e13\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01 --<\/option>';\n                    \n                    province.map((item) => {\n                        let htmlText = '';\n                        if(item.type == \"\u0e1a\u0e38\u0e04\u0e04\u0e25\u0e18\u0e23\u0e23\u0e21\u0e14\u0e32\"){\n                            htmlText = `<option value=\"${item.id}\">${item.first_name} ${item.last_name}<\/option>`;\n                        }else{\n                            htmlText = `<option value=\"${item.id}\">${item.corporation}<\/option>`;\n                        }\n\n                        elementInstance += htmlText\n                    });\n\n                    loopDiv.innerHTML = elementInstance;\n                    \n                    \/\/ You can manipulate DOM or process the data here\n                },\n                error: function(xhr, status, error) {\n                    \/\/ Handle errors\n                    console.error('AJAX Error:', status, error);\n                }\n            });\n        });\n    }\n\n    function sendOrder(){\n\n                    \/\/test area\n                    \/\/return null;\n\n        let data = {\n            customer: {\n                name: document.getElementById('name').value,\n                phone: document.getElementById('phone').value,\n                type: document.getElementById('type').value,\n                address: document.getElementById('address').value,\n                district_id: district_id,\n            },\n            address: document.getElementById('oaddress').value,\n            district_id: odistrict_id,\n            products: products,\n            total: totalPrice\n        }\n\n        if(customer_id !== null && ctype == 1){\n            data.customer_id = customer_id\n        }\n\n        if(products.length < 1){\n            alert('\u0e01\u0e23\u0e38\u0e13\u0e32 \u0e40\u0e25\u0e37\u0e2d\u0e01\u0e2a\u0e34\u0e19\u0e04\u0e49\u0e32');\n        }\n\n        \/\/ console.log(data)\n\n        jQuery(document).ready(function($) {\n\n            $.ajax({\n                url: `https:\/\/api.nongkhaimaibab.com\/api\/wordpress\/sendorder`,\n                type: 'POST',\n                contentType: 'application\/json',\n                data: JSON.stringify(data), \n                headers: { \n                    'ngrok-skip-browser-warning': 'true',\n                },\n                success: function(response) {\n                    localStorage.setItem('carts', JSON.stringify([]));\n                    localStorage.setItem('cart_counting', 0)\n                    loadList();\n\n                    Swal.fire({\n                    title: \"\u0e17\u0e33\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23\u0e2a\u0e33\u0e40\u0e23\u0e47\u0e08\",\n                    text: \"\u0e01\u0e23\u0e38\u0e13\u0e32\u0e23\u0e2d\u0e1e\u0e19\u0e31\u0e01\u0e07\u0e32\u0e19\u0e15\u0e34\u0e14\u0e15\u0e48\u0e2d\u0e01\u0e25\u0e31\u0e1a\",\n                    icon: \"success\"\n                    });\n\n                    location.reload()\n\n                },\n                error: function(xhr, status, error) {\n                    \/\/ Handle errors\n                    console.error('AJAX Error:', status, error);\n                }\n            });\n\n        });\n\n    }\n\n    function selectCustomer(event){\n        customer_id = event.target.value;\n    }\n\n\n    function selectprovince(event){\n        \/\/ console.log(event.target.value)\n        province_id = event.target.value;\n\n        let data = province.find(item => item.id == event.target.value);\n        console.log(data)\n        amphure = data.amphure;\n\n        var loopDiv = document.getElementById('amphure');\n        loopDiv.innerHTML = '';\n        var elementInstance = '<option value=\"\" disable>-- \u0e01\u0e23\u0e38\u0e13\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01 --<\/option>';\n        \n        amphure.map((item) => {\n            let htmlText = `<option value=\"${item.id}\">${item.name_th}<\/option>`;\n\n            elementInstance += htmlText\n        });\n\n        loopDiv.innerHTML = elementInstance;\n\n    }\n\n    function selectAmphure(event){\n                \/\/ console.log(event.target.value)\n        amphure_id = event.target.value;\n\n        let data = amphure.find(item => item.id == event.target.value);\n        console.log(data)\n        district = data.district;\n\n        var loopDiv = document.getElementById('district');\n        loopDiv.innerHTML = '';\n        var elementInstance = '<option value=\"\" disable>-- \u0e01\u0e23\u0e38\u0e13\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01 --<\/option>';\n\n        district.map((item) => {\n            let htmlText = `<option value=\"${item.id}\">${item.name_th}<\/option>`;\n\n            elementInstance += htmlText\n        });\n\n        loopDiv.innerHTML = elementInstance;\n    }\n\n    function selectDistrict(event){\n        district_id = event.target.value;\n    }\n\n\n\n    function oselectprovince(event){\n        \/\/ console.log(event.target.value)\n        oprovince_id = event.target.value;\n\n        let data = province.find(item => item.id == event.target.value);\n        console.log('test',data)\n        oamphure = data.amphure;\n\n        var loopDiv = document.getElementById('oamphure');\n        loopDiv.innerHTML = '';\n        var elementInstance = '<option value=\"\" disable>-- \u0e01\u0e23\u0e38\u0e13\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01 --<\/option>';\n        \n        oamphure.map((item) => {\n            let htmlText = `<option value=\"${item.id}\">${item.name_th}<\/option>`;\n\n            elementInstance += htmlText\n        });\n\n        loopDiv.innerHTML = elementInstance;\n\n    }\n\n    function oselectAmphure(event){\n                \/\/ console.log(event.target.value)\n        oamphure_id = event.target.value;\n\n        let data = oamphure.find(item => item.id == event.target.value);\n        console.log(data)\n        odistrict = data.district;\n\n        var loopDiv = document.getElementById('odistrict');\n        loopDiv.innerHTML = '';\n        var elementInstance = '<option value=\"\" disable>-- \u0e01\u0e23\u0e38\u0e13\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01 --<\/option>';\n\n        odistrict.map((item) => {\n            let htmlText = `<option value=\"${item.id}\">${item.name_th}<\/option>`;\n\n            elementInstance += htmlText\n        });\n\n        loopDiv.innerHTML = elementInstance;\n    }\n\n    function oselectDistrict(event){\n        odistrict_id = event.target.value;\n    }\n\n\n\n    function callprovince() {\n\n        jQuery(document).ready(function($) {\n            \/\/ AJAX request\n            $.ajax({\n                url: `https:\/\/api.nongkhaimaibab.com\/api\/province`,\n                \/\/ url: `https:\/\/7e86-2403-6200-8863-286c-7c03-2ce9-2300-a8b5.ngrok-free.app\/api\/province`,\n                type: 'GET',\n            headers: { \n                'ngrok-skip-browser-warning': 'true',\n            },\n                success: function(response) {\n                    \/\/ Handle the response here\n                    console.log('API response1:', response);\n                    province = response;\n\n\n                    var loopDiv = document.getElementById('province_id');\n                    var oloopDiv = document.getElementById('oprovince_id');\n                    loopDiv.innerHTML = '';\n                    var elementInstance = '<option value=\"\" disable>-- \u0e01\u0e23\u0e38\u0e13\u0e32\u0e40\u0e25\u0e37\u0e2d\u0e01 --<\/option>';\n                    \n                    province.map((item) => {\n                        let htmlText = `<option value=\"${item.id}\">${item.name_th}<\/option>`;\n\n                        elementInstance += htmlText\n                    });\n\n                    loopDiv.innerHTML = elementInstance;\n                    oloopDiv.innerHTML = elementInstance;\n                    \n                    \/\/ You can manipulate DOM or process the data here\n                },\n                error: function(xhr, status, error) {\n                    \/\/ Handle errors\n                    console.error('AJAX Error:', status, error);\n                }\n            });\n        });\n\n    }\n\n    function loadList(){\n        var loopDiv = document.getElementById('tableProductList');\n        var elementInstance = `\n                                <tr class=\"cart_table_head\">\n                                    <th><p class=\"font-16px font-w-500\">\u0e25\u0e33\u0e14\u0e31\u0e1a<\/p><\/th>\n                                    <th class=\"\" style=\"width:35%\"><p class=\"font-16px font-w-500\">\u0e0a\u0e37\u0e48\u0e2d\u0e2a\u0e34\u0e19\u0e04\u0e49\u0e32 \/ \u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14<\/p><\/th>\n                                    <th style=\"width:5%\"><p class=\"font-16px font-w-500\">\u0e08\u0e33\u0e19\u0e27\u0e19<\/p><\/th>\n                                    <th style=\"width:15%\"><p class=\"font-16px font-w-500\">\u0e23\u0e32\u0e04\u0e32\u0e15\u0e48\u0e2d\u0e2b\u0e19\u0e48\u0e27\u0e22<\/p><\/th>\n                                    <th style=\"width:15%\"><p class=\"font-16px font-w-500\">\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 \u0e40\u0e0a\u0e48\u0e32 \/ \u0e0b\u0e37\u0e49\u0e2d<\/p><\/th>\n                                    <th style=\"width:10%\"><p class=\"font-16px font-w-500\">\u0e23\u0e32\u0e04\u0e32\u0e23\u0e27\u0e21<\/p><\/th>\n                                    <th style=\"width:10%\"><p class=\"font-16px font-w-500\"><\/p><\/th>\n                                <\/tr>\n                                `;\n\n        products.map((item, index) => {\n            let price = item.sale_type == 'hire' ? item.hire_per_day : item.sale_price;\n            let htmlText = `\n                <tr>\n                        <td class=\"font-16px font-w-300\">${index + 1}<\/td>\n                        <td class=\"font-16px font-w-300\">${item.name}<\/td>\n                        <td class=\"font-16px font-w-300\"><input type=\"number\" value=\"${item.qty}\" min=\"1\" max=\"${Number(item.quantity)}\" onChange=\"updateqty(event, ${index})\"><\/td>\n                        <td class=\"font-16px font-w-300\">${price}<\/td>\n                        <td class=\"font-16px font-w-300\">19\/05\/2026<\/td>\n                        <td class=\"font-16px font-w-300\" id=\"tprice${index}\">${ item.total }<\/td>\n                        <td class=\"font-16px font-w-300 text-org cursir_p\"><div onClick=\"p_del(${index})\">\u0e25\u0e1a<\/div><\/td>\n                    <\/tr>\n                `;\n\n                elementInstance += htmlText\n        });\n\n        loopDiv.innerHTML = elementInstance;\n\n        loadTotalPrice();\n    }\n\n    function updateqty(event, index){\n        let newVal = event.target.value\n        \/\/ let products = JSON.parse(localStorage.getItem('carts'));\n\n        products[index].qty = newVal;\n\n        let price = products[index].sale_type == 'hire' ? products[index].hire_per_day : products[index].sale_price;\n        let tprice = Number(price * newVal);\n\n        products[index].total = tprice;\n\n        let id = `tprice${index}`;\n        document.getElementById(id).innerHTML = tprice;\n\n        \/\/ console.log(products)\n\n        localStorage.setItem('carts', JSON.stringify(products));\n        loadTotalPrice();\n\n\n    }\n\n    function p_del(index){\n        products.splice(index, 1);\n\n        localStorage.setItem('carts', JSON.stringify(products));\n\n        localStorage.setItem('cart_counting', products.length);\n\n        loadList();\n    }\n\n    function loadTotalPrice(){\n        totalPrice = 0\n        products.map((item, index) => {\n            totalPrice += item.total;\n        });\n\n        document.getElementById('totalPrice').innerHTML = totalPrice\n    }\n<\/script>\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1246","page","type-page","status-publish"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/pages\/1246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/comments?post=1246"}],"version-history":[{"count":3,"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/pages\/1246\/revisions"}],"predecessor-version":[{"id":1742,"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/pages\/1246\/revisions\/1742"}],"wp:attachment":[{"href":"https:\/\/www.nongkhaimaibab.com\/en\/wp-json\/wp\/v2\/media?parent=1246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}