{"id":513,"date":"2026-07-13T11:57:46","date_gmt":"2026-07-13T11:57:46","guid":{"rendered":"https:\/\/ets-moheb.com\/?page_id=513"},"modified":"2026-07-14T15:20:34","modified_gmt":"2026-07-14T15:20:34","slug":"add-product","status":"publish","type":"page","link":"https:\/\/ets-moheb.com\/index.php\/add-product\/","title":{"rendered":"Add Product"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"513\" class=\"elementor elementor-513\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-1168324 e-flex e-con-boxed e-con e-parent\" data-id=\"1168324\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-68232f4 elementor-widget elementor-widget-html\" data-id=\"68232f4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t\n<div class=\"etsm-ap-wrap\" id=\"etsmApp\">\n  <div class=\"etsm-ap-card\">\n    <div class=\"etsm-ap-header\">\n      <span class=\"etsm-ap-eyebrow\">Team Tools<\/span>\n      <h1>Add a Product<\/h1>\n      <p class=\"etsm-ap-sub\">Sign in to add a new product to the catalogue.<\/p>\n    <\/div>\n\n    <form id=\"etsmLoginForm\" class=\"etsm-ap-form\">\n      <div class=\"etsm-ap-field\">\n        <label>Username<\/label>\n        <input type=\"text\" id=\"etsmUser\" autocomplete=\"username\" required=\"\">\n      <\/div>\n      <div class=\"etsm-ap-field\">\n        <label>Password<\/label>\n        <input type=\"password\" id=\"etsmPass\" autocomplete=\"current-password\" required=\"\">\n      <\/div>\n      <div class=\"etsm-ap-error\" id=\"etsmLoginError\" style=\"display:none;\"><\/div>\n      <button type=\"submit\" class=\"etsm-btn etsm-btn-orange\" id=\"etsmLoginBtn\">Sign In<\/button>\n    <\/form>\n\n    <form id=\"etsmProductForm\" class=\"etsm-ap-form\" style=\"display:none;\">\n      <div class=\"etsm-ap-welcome\">Signed in as <strong id=\"etsmWhoAmI\"><\/strong> \u00b7 <a href=\"#\" id=\"etsmLogoutLink\">Sign out<\/a> \u00b7 <a href=\"https:\/\/ets-moheb.com\/index.php\/manage-products\/\">Manage Products<\/a><\/div>\n\n      <div class=\"etsm-ap-field\"><label>Product Name *<\/label><input type=\"text\" id=\"etsmPName\" required=\"\"><\/div><div class=\"etsm-ap-field\"><label>Category *<\/label><select id=\"etsmPCategory\" required=\"\"><option value=\"\">Select a category...<\/option><optgroup label=\"Turning\"><option value=\"39\">External Turning Tools<\/option><option value=\"33\">External Turning Inserts<\/option><option value=\"40\">Internal Turning Tools<\/option><option value=\"41\">Internal Turning Inserts<\/option><\/optgroup><optgroup label=\"Milling\"><option value=\"42\">Indexable Mills<\/option><option value=\"43\">Inserts<\/option><option value=\"44\">Solid Carbide<\/option><option value=\"45\">HSS-Co<\/option><\/optgroup><optgroup label=\"Drilling\"><option value=\"46\">Indexable Drills<\/option><option value=\"47\">Inserts<\/option><option value=\"48\">Solid Carbide<\/option><option value=\"49\">HSS-Co<\/option><\/optgroup><optgroup label=\"Threading\"><option value=\"50\">Thread Turning<\/option><option value=\"51\">Thread Milling<\/option><option value=\"52\">Machine Taps<\/option><\/optgroup><optgroup label=\"Parting and Grooving\"><option value=\"53\">External<\/option><option value=\"54\">Internal<\/option><option value=\"55\">Face Grooving<\/option><\/optgroup><\/select><\/div>\n      <div class=\"etsm-ap-row\">\n        <div class=\"etsm-ap-field\"><label>Material<\/label><input type=\"text\" id=\"etsmPMaterial\" placeholder=\"e.g. Carbide\"><\/div>\n        <div class=\"etsm-ap-field\"><label>Family \/ ISO Shape<\/label><input type=\"text\" id=\"etsmPFamily\" placeholder=\"e.g. CNMG\"><\/div>\n      <\/div>\n      <div class=\"etsm-ap-row\">\n        <div class=\"etsm-ap-field\"><label>Size<\/label><input type=\"text\" id=\"etsmPSize\" placeholder=\"e.g. 12x12\"><\/div>\n        <div class=\"etsm-ap-field\"><label>Status<\/label>\n          <select id=\"etsmPStatus\">\n            <option>In Stock<\/option>\n            <option>On Order<\/option>\n            <option>Discontinued<\/option>\n          <\/select>\n        <\/div>\n      <\/div>\n      <div class=\"etsm-ap-field\"><label>Short Description<\/label><textarea id=\"etsmPDesc\" rows=\"3\" placeholder=\"Brief description shown on the product card\"><\/textarea><\/div>\n      <div class=\"etsm-ap-field\"><label>Product Photo<\/label><input type=\"file\" id=\"etsmPImage\" accept=\"image\/*\"><\/div>\n\n      <div class=\"etsm-ap-error\" id=\"etsmProductError\" style=\"display:none;\"><\/div>\n      <div class=\"etsm-ap-success\" id=\"etsmProductSuccess\" style=\"display:none;\"><\/div>\n\n      <button type=\"submit\" class=\"etsm-btn etsm-btn-orange\" id=\"etsmSubmitBtn\">Add Product<\/button>\n    <\/form>\n  <\/div>\n<\/div>\n\n<style>\n#etsmApp{ font-family:var(--etsm-font); max-width:560px; margin:60px auto; padding:0 20px; }\n.etsm-ap-card{ background:var(--etsm-white); border:1px solid var(--etsm-gray-el); border-radius:16px; box-shadow:0 20px 48px rgba(10,27,48,0.14); padding:44px 40px; box-sizing:border-box; }\n.etsm-ap-eyebrow{ display:inline-block; color:var(--etsm-orange); font-weight:700; font-size:12px; letter-spacing:1.5px; text-transform:uppercase; margin-bottom:10px; }\n.etsm-ap-header h1{ color:var(--etsm-navy-2); font-size:28px; font-weight:700; margin:0 0 8px; }\n.etsm-ap-sub{ color:#6b7683; font-size:14px; margin:0 0 28px; }\n.etsm-ap-field{ margin-bottom:18px; flex:1; }\n.etsm-ap-row{ display:flex; gap:16px; }\n.etsm-ap-field label{ display:block; font-size:13px; font-weight:600; color:var(--etsm-navy-2); margin-bottom:6px; }\n.etsm-ap-field input, .etsm-ap-field select, .etsm-ap-field textarea{ width:100%; border:1.5px solid var(--etsm-gray-el); border-radius:8px; padding:12px 14px; font-size:14px; font-family:var(--etsm-font); background:var(--etsm-white); box-sizing:border-box; }\n.etsm-ap-field input:focus, .etsm-ap-field select:focus, .etsm-ap-field textarea:focus{ outline:none; border-color:var(--etsm-orange); box-shadow:0 0 0 3px rgba(255,102,0,0.12); }\n.etsm-ap-wrap .etsm-btn{ display:inline-block; text-decoration:none; text-align:center; width:100%; border:none; border-radius:8px; padding:14px 30px; font-weight:700; font-size:15px; font-family:var(--etsm-font); cursor:pointer; }\n.etsm-ap-wrap .etsm-btn-orange{ background:var(--etsm-orange); color:#fff; }\n.etsm-ap-wrap .etsm-btn-orange:hover{ background:#e65c00; }\n.etsm-ap-wrap .etsm-btn-orange:disabled{ opacity:0.6; cursor:not-allowed; }\n.etsm-ap-error{ background:#fdecea; border:1px solid #f5b5ad; color:#9a2f24; border-radius:8px; padding:10px 14px; font-size:13px; margin-bottom:16px; }\n.etsm-ap-success{ background:#eaf7ee; border:1px solid #a9dcb8; color:#1e6b33; border-radius:8px; padding:10px 14px; font-size:13px; margin-bottom:16px; }\n.etsm-ap-welcome{ font-size:13px; color:#6b7683; margin-bottom:20px; }\n.etsm-ap-welcome a{ color:var(--etsm-orange); font-weight:600; text-decoration:none; }\n@media (max-width:520px){ .etsm-ap-row{ flex-direction:column; gap:0; } .etsm-ap-card{ padding:32px 24px; } }\n<\/style>\n\n<script>\n(function(){\n  const loginForm = document.getElementById('etsmLoginForm');\n  const productForm = document.getElementById('etsmProductForm');\n  const loginErr = document.getElementById('etsmLoginError');\n  const prodErr = document.getElementById('etsmProductError');\n  const prodOk = document.getElementById('etsmProductSuccess');\n  if (!loginForm) return;\n  let NONCE = null;\n\n  window.addEventListener('load', function() {\n    if (window.etsmServerNonce) {\n      NONCE = window.etsmServerNonce;\n      document.getElementById('etsmWhoAmI').textContent = window.etsmServerName || 'pola';\n      loginForm.style.display = 'none';\n      productForm.style.display = 'block';\n    }\n  });\n\n  loginForm.addEventListener('submit', async function(e){\n    e.preventDefault();\n    loginErr.style.display = 'none';\n    const btn = document.getElementById('etsmLoginBtn');\n    btn.disabled = true; btn.textContent = 'Signing in...';\n    try {\n      const res = await fetch('\/wp-json\/etsm\/v1\/login', {\n        method:'POST', credentials:'same-origin',\n        headers:{'Content-Type':'application\/json'},\n        body: JSON.stringify({\n          username: document.getElementById('etsmUser').value.trim(),\n          password: document.getElementById('etsmPass').value\n        })\n      });\n      const data = await res.json();\n      if (!res.ok || !data.success) { throw new Error(data.message || 'Login failed.'); }\n      NONCE = data.nonce;\n      document.getElementById('etsmWhoAmI').textContent = data.display_name;\n      loginForm.style.display = 'none';\n      productForm.style.display = 'block';\n      document.getElementById('etsmPass').value = '';\n    } catch (err) {\n      loginErr.textContent = err.message;\n      loginErr.style.display = 'block';\n    } finally {\n      btn.disabled = false; btn.textContent = 'Sign In';\n    }\n  });\n\n  document.getElementById('etsmLogoutLink').addEventListener('click', async function(e){\n    e.preventDefault();\n    try { await fetch('\/wp-json\/etsm\/v1\/logout', {method:'POST', credentials:'same-origin'}); } catch(err){}\n    NONCE = null;\n    productForm.style.display = 'none';\n    productForm.reset();\n    loginForm.style.display = 'block';\n    document.getElementById('etsmUser').value='';\n  });\n\n  productForm.addEventListener('submit', async function(e){\n    e.preventDefault();\n    prodErr.style.display='none'; prodOk.style.display='none';\n    const btn = document.getElementById('etsmSubmitBtn');\n    btn.disabled = true; btn.textContent = 'Adding...';\n    try {\n      const name = document.getElementById('etsmPName').value.trim();\n      if (!name) throw new Error('Product name is required.');\n      const material = document.getElementById('etsmPMaterial').value.trim();\n      const family = document.getElementById('etsmPFamily').value.trim();\n      const size = document.getElementById('etsmPSize').value.trim();\n      const status = document.getElementById('etsmPStatus').value;\n      const desc = document.getElementById('etsmPDesc').value.trim();\n      const fileInput = document.getElementById('etsmPImage');\n\n      let imageId = null;\n      if (fileInput.files && fileInput.files[0]) {\n        const fd = new FormData();\n        fd.append('file', fileInput.files[0], fileInput.files[0].name);\n        const mediaRes = await fetch('\/wp-json\/wp\/v2\/media', {\n          method:'POST', credentials:'same-origin',\n          headers: {'X-WP-Nonce': NONCE},\n          body: fd\n        });\n        const mediaData = await mediaRes.json();\n        if (!mediaRes.ok) throw new Error(mediaData.message || 'Image upload failed.');\n        imageId = mediaData.id;\n      }\n\n      const attributes = [];\n      if (material) attributes.push({name:'Material', options:[material], visible:true});\n      if (family) attributes.push({name:'Family \/ ISO Shape', options:[family], visible:true});\n      if (size) attributes.push({name:'Size', options:[size], visible:true});\n      if (status) attributes.push({name:'Status', options:[status], visible:true});\n\n      const payload = {\n        name: name,\n        type: 'external',\n        external_url: 'https:\/\/ets-moheb.com\/index.php\/contact-us-4\/',\n        button_text: 'Request a Quote',\n        short_description: desc,\n        categories:[{id: parseInt(document.getElementById('etsmPCategory').value, 10)}],\n        status: 'publish',\n        attributes: attributes\n      };\n      if (imageId) payload.images = [{id: imageId}];\n\n      const prodRes = await fetch('\/wp-json\/wc\/v3\/products', {\n        method:'POST', credentials:'same-origin',\n        headers: {'Content-Type':'application\/json','X-WP-Nonce': NONCE},\n        body: JSON.stringify(payload)\n      });\n      const prodData = await prodRes.json();\n      if (!prodRes.ok) throw new Error(prodData.message || 'Could not create the product.');\n\n      prodOk.innerHTML = 'Product added! <a href=\"' + prodData.permalink + '\" target=\"_blank\">View it on the Products page<\/a>.';\n      prodOk.style.display = 'block';\n      productForm.reset();\n    } catch(err) {\n      prodErr.textContent = err.message;\n      prodErr.style.display = 'block';\n    } finally {\n      btn.disabled = false; btn.textContent = 'Add Product';\n    }\n  });\n})();\n<\/script>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Team Tools Add a Product Sign in to add a new product to the catalogue. Username Password Sign In Signed in as \u00b7 Sign out \u00b7 Manage Products Product Name *Category *Select a category&#8230;External Turning ToolsExternal Turning InsertsInternal Turning ToolsInternal Turning InsertsIndexable MillsInsertsSolid CarbideHSS-CoIndexable DrillsInsertsSolid CarbideHSS-CoThread TurningThread MillingMachine TapsExternalInternalFace Grooving Material Family \/ ISO Shape [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-513","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/pages\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/comments?post=513"}],"version-history":[{"count":22,"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/pages\/513\/revisions"}],"predecessor-version":[{"id":556,"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/pages\/513\/revisions\/556"}],"wp:attachment":[{"href":"https:\/\/ets-moheb.com\/index.php\/wp-json\/wp\/v2\/media?parent=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}