========================================================================== */
(function () {
'use strict';
// WooCommerce 주소 편집 폼 페이지 (/edit-address/shipping 등)
var addressForm = document.querySelector('.woocommerce-address-fields');
if (addressForm) {
initAddressEdit();
return;
}
// WooCommerce 주소 표시 페이지 (/edit-address/)
var addressDisplay = document.querySelector('.woocommerce-Addresses');
if (addressDisplay) {
initInlineAddressForm();
}
/* --------------------------------------------------------------------------
주소 표시 페이지 → 인라인 편집 폼으로 교체
-------------------------------------------------------------------------- */
function initInlineAddressForm() {
var addressColumns = addressDisplay.querySelectorAll('.woocommerce-Address');
addressColumns.forEach(function (col) {
var header = col.querySelector('.woocommerce-Address-title');
var addressEl = col.querySelector('address');
var editLink = col.querySelector('a.edit');
if (!addressEl) return;
// shipping / billing 구분
var type = 'shipping';
if (col.classList.contains('u-column2') || (editLink && editLink.href.indexOf('billing') > -1)) {
type = 'billing';
}
// 기존 주소 파싱
var parsed = parseAddress(addressEl.innerHTML);
// 기존 주소 표시 숨기기
addressEl.style.display = 'none';
if (editLink) editLink.style.display = 'none';
// 인라인 편집 폼 생성
var form = createAddressForm(type, parsed);
col.appendChild(form);
});
}
/* --------------------------------------------------------------------------
기존 주소 HTML 파싱
-------------------------------------------------------------------------- */
function parseAddress(html) {
var parts = html.split('
').map(function (s) {
return s.replace(/<[^>]*>/g, '').trim();
}).filter(Boolean);
// WooCommerce KR 주소 형식: 이름 / 주소1 / 주소2 / 시도 / 우편번호
return {
name: parts[0] || '',
address1: parts[1] || '',
address2: parts[2] || '',
state: parts[3] || '',
postcode: parts[4] || '',
phone: parts[5] || ''
};
}
/* --------------------------------------------------------------------------
인라인 주소 편집 폼 생성
-------------------------------------------------------------------------- */
function createAddressForm(type, parsed) {
var wrapper = document.createElement('div');
wrapper.className = 'feedus-address-inline-edit';
wrapper.innerHTML =
'
Sample Page
This is an example page. It’s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)
…or something like this:
The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.
As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!