feat: migrate shipping to form-level and integrate flags.json as single source of truth

Shipping Migration:
- Move shipping configuration from product-level to form-level
- Add form shipping tab in form settings (no_shipping, flat_rate, free_shipping)
- Update FlatRate to register at form level instead of product level
- Update checkout logic to read from form settings
- Support percentage-based flat rate calculation
- Simplify shipping method IDs (flat_rate, free_shipping)

Currency Flags Integration:
- Add formipay_get_all_currency_flags() to read from admin/assets/json/flags.json
- Remove hardcoded CURRENCY_FLAGS emoji map from VariationField.js
- Create CurrencyFlag component to render base64 flag images
- Localize currency_flags to window.formipayProductDetails
- Update shipping info display in admin order details

Benefits:
- Form-level shipping prevents multiplying shipping costs per product
- Single source of truth for currency flags (flags.json)
- Better support for future cart system
- Consistent with e-commerce standards
This commit is contained in:
dwindown
2026-04-23 08:12:40 +07:00
parent 0094a3571c
commit 008188b790
13 changed files with 2819 additions and 797 deletions

View File

@@ -64,6 +64,28 @@ jQuery(function($){
$('#order-total').html(res.total_formatted);
$('#order_status').val(res.status);
// Populate shipping info if available
var shippingInfo = [];
if(res.form_data){
$.each(res.form_data, function(key, data){
if(data.name === 'shipping_country' || data.name === 'shipping_method'){
shippingInfo.push(data);
}
});
}
if(shippingInfo.length > 0){
var source = $("#shipping-info-template").html();
var template = Handlebars.compile(source);
var context = {
datas: shippingInfo
};
var html = template(context);
$("#shipping-info-list").html(html);
} else {
$("#shipping-info-list").addClass('d-none');
$('#no-shipping-info').removeClass('d-none');
}
var source = $("#form-data-item-template").html();
var template = Handlebars.compile(source);
var context = {