Woocommerce "your cart is currently empty"但仅在预览模式之外?(自定义结帐表格)



在WordPress中我使用了" In -page"结帐自定义表单,人们直接在显示产品的页面中填写表单,他们可以直接从那里付款,而不需要经过购物车页面。

它工作得很好,而我在预览模式和在同一个Chrome窗口:订单得到处理,我可以支付任何和一切只是工作。然而,如果我在另一个窗口或浏览器(或我的手机)打开页面,在我按下按钮确认订单后,我收到的是"您的购物车是空的";页,不处理任何订单。真奇怪,它只能在预览模式下工作。

我已经从我的托管域清除了所有可能的缓存,甚至从我的浏览器中清除了该网站的cookie,但它仍然不起作用。

如果有帮助的话,这是结帐表单的自定义代码:

<?php
// In page checkout form
setlocale(LC_TIME, "it_IT");
$productId = $GLOBALS['inpage_form_product'];
$options = $GLOBALS['inpage_form_options'];
wp_enqueue_style('inpage-form', get_template_directory_uri() . ($options['inpage_form_style'] ?? '/inpage-form.css'));
wp_enqueue_script('inpage-form', get_template_directory_uri() . '/assets/js/inpage-form.js');
$product = wc_get_product($productId);
$variations = $product->get_available_variations();
$variations = array_map(function ($variation) use ($options) {
return [
'id' => $variation['variation_id'],
'label' => $variation['attributes']['attribute_quantita'],
'price' => $variation['display_price'],
'regular_price' => $variation['display_regular_price'],
'quantity' => strip_tags($variation['variation_description']),
'highlight' => $options['highlight_label_' . $variation['variation_id']] ?? false,
'highlight_color' => $options['highlight_label_color_' . $variation['variation_id']] ?? false,
];
}, $variations);
$initialVariation = $variations[0];
function formatPrice($price)
{
echo number_format($price, 2, ',', '') . '€';
}
WC()->cart->empty_cart();
WC()->cart->add_to_cart($productId, 1, $initialVariation['id']);
if(class_exists('WC_Gateway_Stripe')) {
$stripe = new WC_Gateway_Stripe();
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), [], WC_STRIPE_VERSION);
wp_enqueue_style('stripe_styles');
wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), ['jquery-payment', 'stripe'], WC_STRIPE_VERSION, true);
wp_register_script('woocommerce_gateway_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), ['jquery-payment', 'stripe'], WC_STRIPE_VERSION, true);
wp_localize_script(
'woocommerce_stripe',
'wc_stripe_params',
apply_filters('wc_stripe_params', $stripe->javascript_params())
);
$stripe->tokenization_script();
wp_enqueue_script('woocommerce_stripe');
}

wp_enqueue_script('wc-country-select');
wp_enqueue_script('selectWoo');
wp_enqueue_style('select2');
$shippingMethods = WC()->shipping()->get_packages()[0]['rates'];
$chosenMethod = isset(WC()->session->chosen_shipping_methods[0]) ? WC()->session->chosen_shipping_methods[0] : '';
function business_day($days, $abbrv = false)
{
if($abbrv) {
return utf8_encode(strtolower(strftime('%a %e. %m.', strtotime("+$days weekdays"))));
}
return utf8_encode(strtolower(strftime('%A', strtotime("+$days weekdays"))));
}
function add_delivery_payment_info()
{
printf('<div class="inpage-form__delivery_payment">');
printf('<div class="inpage-form__delivery_payment__wrapper">');
printf('<div>');
printf('<div class="inpage-form__delivery_payment__title">Oggi non paghi niente!</div>');
printf('<div class="inpage-form__delivery_payment__description">Paghi alla consegna 😁</div>');
printf('</div>');
printf('
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m19 4.86-8.991 4.383-3.501-1.701-1.458-.711-4.05-1.971 8.991-4.374 3.834 1.864 1.53.738z" fill="#ffa726"/><path d="m9.99 19.779-9.49-4.939v-9.48l9.49 4.37z" fill="#ffcc80"/><path d="m19.5 5.36v9.48l-9.49 4.939v-10.049z" fill="#ffb74d"/><path d="m17.5 23.4c-.142 0-.283-.044-.403-.133-.558-.415-5.447-4.141-5.447-7.302 0-1.855 1.514-3.364 3.375-3.364.957 0 1.848.401 2.475 1.074.627-.673 1.518-1.074 2.475-1.074 1.861 0 3.375 1.509 3.375 3.364 0 3.161-4.89 6.888-5.447 7.302-.12.089-.261.133-.403.133z" fill="#f44336"/><path d="m17.5 24c-.157 0-.314-.05-.447-.148-.62-.46-6.053-4.601-6.053-8.114 0-2.061 1.682-3.738 3.75-3.738 1.063 0 2.054.446 2.75 1.194.696-.748 1.687-1.194 2.75-1.194 2.068 0 3.75 1.677 3.75 3.738 0 3.513-5.433 7.653-6.053 8.113-.133.099-.29.149-.447.149zm-2.75-10.5c-1.241 0-2.25 1.004-2.25 2.238 0 2.142 3.276 5.191 5 6.564 1.724-1.374 5-4.427 5-6.564 0-1.234-1.009-2.238-2.25-2.238-.897 0-1.707.527-2.062 1.343-.238.547-1.137.547-1.375 0-.356-.816-1.166-1.343-2.063-1.343z"/><path d="m10.007 10.5c-.278 0-.545-.155-.675-.422-.181-.372-.026-.821.346-1.002l9.244-4.5c.234-.114.507-.099.726.039.219.136.352.377.352.635v4c0 .414-.336.75-.75.75s-.75-.336-.75-.75v-2.801l-8.166 3.975c-.105.052-.217.076-.327.076z"/><path d="m9.25 20c-.125 0-.25-.03-.366-.096l-8.5-4.75c-.237-.132-.384-.383-.384-.654v-9.25c0-.258.133-.499.353-.636.218-.138.493-.153.726-.039l9.244 4.5c.373.181.527.63.346 1.002-.182.373-.632.525-1.002.346l-8.167-3.974v7.61l8.116 4.536c.362.201.491.658.289 1.021-.137.245-.393.384-.655.384z"/><path d="m.75 6c-.277 0-.544-.155-.674-.422-.181-.372-.026-.821.346-1.002l9.244-4.5c.207-.101.449-.101.656 0l9.256 4.5c.373.181.527.63.346 1.002s-.629.529-1.002.346l-8.928-4.34-8.916 4.34c-.105.052-.217.076-.328.076z"/><path d="m5.25 11.99c-.414 0-.75-.336-.75-.75v-3.8c0-.283.16-.542.413-.67l9.09-4.581c.369-.186.82-.038 1.007.333.186.37.038.821-.333 1.007l-8.677 4.373v3.338c0 .414-.336.75-.75.75z"/></svg>');
printf('</div>');
printf('</div>');
}
add_action('woocommerce_review_order_before_submit', 'add_delivery_payment_info');
?>
<div class="inpage-form" data-product-id="<?php echo $productId; ?>">
<div class="inpage-form__form-card">
<h4>Modulo d’ordine</h4>
<div class="inpage-form__total">
<span class="inpage-form__regular-price"><?php formatPrice($initialVariation['regular_price']); ?></span>
<span class="inpage-form__price"><?php formatPrice($initialVariation['price']); ?></span>
</div>
<!--<div class="inpage-form__countdown">
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512"
xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="m6.5 19h-2c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h2c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m22.75 19h-1.25c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h.835l.674-3.592c-.009-1.838-1.579-3.408-3.509-3.408h-3.283l-1.591 7h2.874c.276 0 .5.224.5.5s-.224.5-.5.5h-3.5c-.152 0-.296-.069-.391-.188-.095-.118-.131-.274-.097-.422l1.818-8c.052-.229.254-.39.488-.39h3.682c2.481 0 4.5 2.019 4.5 4.5l-.759 4.092c-.044.237-.25.408-.491.408z"/>
<path d="m19.5 21c-1.378 0-2.5-1.121-2.5-2.5s1.122-2.5 2.5-2.5 2.5 1.121 2.5 2.5-1.122 2.5-2.5 2.5zm0-4c-.827 0-1.5.673-1.5 1.5s.673 1.5 1.5 1.5 1.5-.673 1.5-1.5-.673-1.5-1.5-1.5z"/>
<path d="m8.5 21c-1.378 0-2.5-1.121-2.5-2.5s1.122-2.5 2.5-2.5 2.5 1.121 2.5 2.5-1.122 2.5-2.5 2.5zm0-4c-.827 0-1.5.673-1.5 1.5s.673 1.5 1.5 1.5 1.5-.673 1.5-1.5-.673-1.5-1.5-1.5z"/>
<path d="m6.5 10h-4c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h4c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m6.5 13h-5c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h5c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m6.5 16h-6c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h6c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m14 19h-3.5c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h3.101l2.272-10h-11.373c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h12c.152 0 .296.069.391.188.095.118.131.274.097.422l-2.5 11c-.052.229-.255.39-.488.39z"/>
</svg>
<div>
<div class="inpage-form__countdown__title">Affrettati con l'acquisto</div>
<div class="inpage-form__countdown__description">Se ordini entro
<time class="inpage-form__countdown_hook">30:00</time>
minuti riceverai <strong><?php //echo business_day(2); ?></strong></div>
<div class="inpage-form__countdown__description">Se ordini entro
<time class="inpage-form__countdowner_hook">30:00</time>
minuti riceverai <strong><? //php echo business_day(2); ?></strong></div>
</div>
</div>-->
<?php if(count($variations) > 1): ?>
<ul class="inpage-form__options">
<?php foreach ($variations as $variation) :
$singlePrice = $variation['price'] / (float) $variation['quantity'];
?>
<li class="inpage-form__option <?php echo $variation['highlight'] ? 'inpage-form__option-highlight' : ''; ?>">
<input
type="radio"
name="quantity"
id="option-<?php echo $variation['id']; ?>" value="<?php echo $variation['id']; ?>"
data-regular-price="<?php echo $variation['regular_price']; ?>"
data-price="<?php echo $variation['price']; ?>"
/>
<?php if ($variation['highlight']) { ?>
<div class="inpage-form__option-top" <?php echo $variation['highlight_color'] ? 'style="background-color:'. $variation['highlight_color'].'"' : ''; ?>>
<?php echo $variation['highlight']; ?>
</div>
<?php } ?>
<label for="option-<?php echo $variation['id']; ?>">
<span class="inpage-form__quantity"><?php echo $variation['quantity']; ?><small>x</small></span>
<span class="inpage-form__option-main">
<span class="inpage-form__single-price"><?php formatPrice($singlePrice); ?></span>
<span class="inpage-form__quantity-info">a pezzo</span>
</span>
</label>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="inpage-form__checkout">
<form name="checkout" method="post" class="checkout woocommerce-checkout"
action="<?php echo esc_url(wc_get_checkout_url()); ?>" enctype="multipart/form-data">
<div class="woocommerce-billing-fields__field-wrapper">
<p class="form-row form-row-wide validate-required validate-email" id="billing_email_field"
data-priority="110">
<input type="email" class="input-text" name="billing_email" id="billing_email"
placeholder="Indirizzo email " value="" autocomplete="email username"/>
<label for="billing_email" class="">Indirizzo email</label>
</p>
<p class="form-row form-row-wide validate-required validate-phone" id="billing_phone_field"
data-priority="100">
<input type="tel" class="input-text "
name="billing_phone" id="billing_phone"
placeholder="Telefono" value=""
autocomplete="tel"/>
<label for="billing_phone" class="">Telefono</label>
</p>
<div class="inpage-form__form-row-online">
<p class="form-row form-row-first validate-required" id="billing_first_name_field"
data-priority="10">
<input type="text" class="input-text " name="billing_first_name" id="billing_first_name"
placeholder="Nome" value="" autocomplete="given-name"/>
<label for="billing_first_name" class="">Nome</label>
</p>
<p class="form-row form-row-last validate-required" id="billing_last_name_field"
data-priority="20">
<input type="text" class="input-text " name="billing_last_name" id="billing_last_name"
placeholder="Cognome" value="" autocomplete="family-name"/>
<label for="billing_last_name" class="">Cognome</label>
</p>
</div>
</div> 

<?php
if($options['insurance_product'] ?? false) :
$insuranceProduct = wc_get_product($options['insurance_product']);
?>
<label class="inpage-form__insurance inpage-form__extras" data-product-id="<?php echo $options['insurance_product']; ?>">
<svg id="color" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m23.491 1.826-5.25-1.786c-.156-.054-.326-.054-.482 0l-5.25 1.786c-.305.103-.509.388-.509.71v4.018c0 4.904 5.474 7.288 5.707 7.387.094.039.193.059.293.059s.199-.02.293-.06c.233-.099 5.707-2.482 5.707-7.386v-4.018c0-.322-.204-.607-.509-.71z" fill="#4caf50"/><path d="m21.286 5.618-2.75 3.5c-.168.214-.417.351-.688.377l-.098.005c-.237 0-.469-.084-.65-.241l-1.75-1.5c-.42-.359-.469-.991-.108-1.41.359-.419.991-.467 1.409-.108l.958.821 2.105-2.679c.341-.434.969-.511 1.404-.168.434.34.51.969.168 1.403z" fill="#fff"/><path d="m18 0h-.019c-.075.002-.15.015-.222.04l-5.25 1.786c-.305.103-.509.388-.509.71v4.018c0 4.904 5.474 7.288 5.707 7.387.094.039.193.059.293.059v-4.532c-.05.013-.101.022-.152.027l-.098.005c-.237 0-.469-.084-.65-.241l-1.75-1.5c-.42-.359-.469-.991-.108-1.41.197-.23.477-.349.759-.349.23 0 .462.079.649.24l.958.821.392-.498z" fill="#429846"/><path d="m16.001 6c-.282 0-.562.118-.76.349-.36.419-.312 1.051.108 1.41l1.75 1.5c.182.157.414.241.651.241l.098-.005c.051-.005.102-.014.152-.027v-2.905l-.392.498-.958-.82c-.188-.162-.419-.241-.649-.241z" fill="#dedede"/><path d="m22 17.5c-2 0-6 2.531-8 2.531s-4.25-1.531-4.25-1.531 2.693.5 4.25.5 2-.531 2-1.25c0-1.75-2.973-2.022-4.476-2.25-1.477-.822-3.037-1.333-5.481-1.54-.015.142-.037.284-.077.425l-2.009 7.08c2.275 1.036 6.986 2.535 9.043 2.535 3 0 11-4 11-5s-1-1.5-2-1.5z" fill="#ffcc80"/><path d="m3.5 22h-2.75c-.414 0-.75-.336-.75-.75v-8.5c0-.414.336-.75.75-.75 3.505 0 5.138 1.216 5.205 1.268.242.185.349.498.27.792l-2 7.386c-.089.327-.386.554-.725.554z" fill="#2196f3"/><path d="m22 17.5c-2 0-6 2.531-8 2.531s-4.25-1.531-4.25-1.531l-4.472-.944-1.053 3.89c-.011.042-.026.081-.044.12 2.348 1.028 6.828 2.434 8.819 2.434 3 0 11-4 11-5s-1-1.5-2-1.5z" fill="#deb26f"/><path d="m0 16.442v4.808c0 .414.336.75.75.75h2.75c.296 0 .56-.173.681-.435.018-.038.032-.078.044-.12l1.053-3.89z" fill="#1d83d4"/></svg>
<div class="inpage-form__insurance__wrapper">
<?php
if($insuranceProduct->get_regular_price() !== $insuranceProduct->get_price()) {
printf('<div class="inpage-form__insurance__title">Assicura il tuo pacchetto a soli <del>%s</del> %s</div>', wc_price($insuranceProduct->get_regular_price()), wc_price($insuranceProduct->get_price()));
} else {
printf('<div class="inpage-form__insurance__title">Assicura il tuo pacchetto a soli %s</div>', wc_price($insuranceProduct->get_price()));
}
?>
<div class="inpage-form__insurance__description">Se il prodotto nella confezione è danneggiato, te ne invieremo uno nuovo senza alcuna domanda.</div>
</div>
<input type="checkbox" name="insurance_enable">
</label>
<?php
endif
?>
<?php
if($options['gift_product'] ?? false) :
$giftProduct = wc_get_product($options['gift_product']);
?>
<label class="inpage-form__gift inpage-form__extras" data-product-id="<?php echo $options['gift_product']; ?>">
<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g fill="#fbe77b"><path d="m214.374 64.52s-64.52-64.52-139.447-64.52c-43.707 0-60.358 29.138-60.358 58.276s17.691 58.276 49.951 58.276h149.854z"/><path d="m214.374 64.52s-64.52-64.52-139.447-64.52c-43.707 0-60.358 29.138-60.358 58.276s17.691 58.276 49.951 58.276h149.854z"/><path d="m297.626 64.52s64.52-64.52 139.447-64.52c43.707 0 60.358 29.138 60.358 58.276s-17.691 58.276-49.951 58.276h-149.854z"/></g><path d="m492 199.805h-472c-11.046 0-20-8.954-20-20v-43.252c0-11.046 8.954-20 20-20h472c11.046 0 20 8.954 20 20v43.252c0 11.046-8.954 20-20 20z" fill="#fb636f"/><path d="m484.943 116.553v83.252h6.453c11.379 0 20.604-9.225 20.604-20.604v-42.045c0-11.379-9.225-20.604-20.604-20.604h-6.453z" fill="#fa4954"/><path d="m193.561 116.553h124.878v83.252h-124.878z" fill="#fbe77b"/><path d="m464.943 512h-417.886c-11.046 0-20-8.954-20-20v-292.195h457.886v292.195c0 11.046-8.954 20-20 20z" fill="#fb636f"/><path d="m27.057 199.805h457.886v24.976h-457.886z" fill="#fa4954"/><path d="m214.374 199.805h83.252v312.195h-83.252z" fill="#fbe77b"/><path d="m214.374 199.805h83.252v24.976h-83.252z" fill="#fcdd2e"/><path d="m326.764 95.74c-4.333 0-8.045-2.65-9.611-6.416 2.685-.986 5.58-1.951 8.585-2.798 4.107-1.158 6.498-5.426 5.341-9.533s-5.425-6.499-9.533-5.341c-1.773.5-3.505 1.035-5.189 1.589v-24.848c-11.859 9.256-18.732 16.127-18.732 16.127v52.033h149.855c17.376 0 30.516-8.46 38.951-20.813z" fill="#fcdd2e"/><path d="m195.642 48.393v24.848c-1.683-.554-3.416-1.089-5.189-1.589-4.104-1.157-8.375 1.233-9.533 5.341-1.157 4.107 1.233 8.375 5.341 9.533 2.998.845 5.895 1.812 8.584 2.8-1.566 3.765-5.278 6.413-9.61 6.413h-159.666c8.435 12.353 21.575 20.813 38.951 20.813h149.854v-52.032s-6.873-6.871-18.732-16.127z" fill="#fcdd2e"/><path d="m297.626 116.553h-83.252v-52.602c0-7.732 6.268-14 14-14h55.252c7.732 0 14 6.268 14 14z" fill="#fbe77b"/><path d="m214.374 95.74h83.252v20.813h-83.252z" fill="#fcdd2e"/></svg>
<div class="inpage-form__gift__wrapper">
<div class="inpage-form__gift__title">Abbiamo un regalo per te!</div>
<?php
if($giftProduct->get_regular_price() !== $giftProduct->get_price()) {
printf('<div class="inpage-form__gift__description">Prodotto esclusivo per te a solo <del>%s</del> <strong>%s</strong></div>', wc_price($giftProduct->get_regular_price()), wc_price($giftProduct->get_price()));
} else {
printf('<div class="inpage-form__gift__description">Prodotto esclusivo per te a solo <strong>%s</strong></div>', wc_price($giftProduct->get_price()));
}
?>
</div>
<input type="checkbox" name="gift_enable">
<div type="button" class="inpage-form__gift__btn">
Aggiungi
</div>
</label>
<?php
endif
?>
<h3>Metodo di pagamento</h3>
<div id="order_review" class="woocommerce-checkout-review-order">
<?php woocommerce_checkout_payment(); ?>
</div>
</form>
</div>
</div>
<!--    --><?php //WC()->checkout()->checkout_form_billing(); ?>
</div>
wc_load_cart();
Use this code use to refresh cart
<?php
// In page checkout form
setlocale(LC_TIME, "it_IT");
$productId = $GLOBALS['inpage_form_product'];
$options = $GLOBALS['inpage_form_options'];
wp_enqueue_style('inpage-form', get_template_directory_uri() . ($options['inpage_form_style'] ?? '/inpage-form.css'));
wp_enqueue_script('inpage-form', get_template_directory_uri() . '/assets/js/inpage-form.js');
$product = wc_get_product($productId);
$variations = $product->get_available_variations();
$variations = array_map(function ($variation) use ($options) {
return [
'id' => $variation['variation_id'],
'label' => $variation['attributes']['attribute_quantita'],
'price' => $variation['display_price'],
'regular_price' => $variation['display_regular_price'],
'quantity' => strip_tags($variation['variation_description']),
'highlight' => $options['highlight_label_' . $variation['variation_id']] ?? false,
'highlight_color' => $options['highlight_label_color_' . $variation['variation_id']] ?? false,
];
}, $variations);
$initialVariation = $variations[0];
function formatPrice($price)
{
echo number_format($price, 2, ',', '') . '€';
}
wc_load_cart();
WC()->cart->empty_cart();
WC()->cart->add_to_cart($productId, 1, $initialVariation['id']);
if(class_exists('WC_Gateway_Stripe')) {
$stripe = new WC_Gateway_Stripe();
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), [], WC_STRIPE_VERSION);
wp_enqueue_style('stripe_styles');
wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), ['jquery-payment', 'stripe'], WC_STRIPE_VERSION, true);
wp_register_script('woocommerce_gateway_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), ['jquery-payment', 'stripe'], WC_STRIPE_VERSION, true);
wp_localize_script(
'woocommerce_stripe',
'wc_stripe_params',
apply_filters('wc_stripe_params', $stripe->javascript_params())
);
$stripe->tokenization_script();
wp_enqueue_script('woocommerce_stripe');
}

wp_enqueue_script('wc-country-select');
wp_enqueue_script('selectWoo');
wp_enqueue_style('select2');
$shippingMethods = WC()->shipping()->get_packages()[0]['rates'];
$chosenMethod = isset(WC()->session->chosen_shipping_methods[0]) ? WC()->session->chosen_shipping_methods[0] : '';
function business_day($days, $abbrv = false)
{
if($abbrv) {
return utf8_encode(strtolower(strftime('%a %e. %m.', strtotime("+$days weekdays"))));
}
return utf8_encode(strtolower(strftime('%A', strtotime("+$days weekdays"))));
}
function add_delivery_payment_info()
{
printf('<div class="inpage-form__delivery_payment">');
printf('<div class="inpage-form__delivery_payment__wrapper">');
printf('<div>');
printf('<div class="inpage-form__delivery_payment__title">Oggi non paghi niente!</div>');
printf('<div class="inpage-form__delivery_payment__description">Paghi alla consegna 😁</div>');
printf('</div>');
printf('
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m19 4.86-8.991 4.383-3.501-1.701-1.458-.711-4.05-1.971 8.991-4.374 3.834 1.864 1.53.738z" fill="#ffa726"/><path d="m9.99 19.779-9.49-4.939v-9.48l9.49 4.37z" fill="#ffcc80"/><path d="m19.5 5.36v9.48l-9.49 4.939v-10.049z" fill="#ffb74d"/><path d="m17.5 23.4c-.142 0-.283-.044-.403-.133-.558-.415-5.447-4.141-5.447-7.302 0-1.855 1.514-3.364 3.375-3.364.957 0 1.848.401 2.475 1.074.627-.673 1.518-1.074 2.475-1.074 1.861 0 3.375 1.509 3.375 3.364 0 3.161-4.89 6.888-5.447 7.302-.12.089-.261.133-.403.133z" fill="#f44336"/><path d="m17.5 24c-.157 0-.314-.05-.447-.148-.62-.46-6.053-4.601-6.053-8.114 0-2.061 1.682-3.738 3.75-3.738 1.063 0 2.054.446 2.75 1.194.696-.748 1.687-1.194 2.75-1.194 2.068 0 3.75 1.677 3.75 3.738 0 3.513-5.433 7.653-6.053 8.113-.133.099-.29.149-.447.149zm-2.75-10.5c-1.241 0-2.25 1.004-2.25 2.238 0 2.142 3.276 5.191 5 6.564 1.724-1.374 5-4.427 5-6.564 0-1.234-1.009-2.238-2.25-2.238-.897 0-1.707.527-2.062 1.343-.238.547-1.137.547-1.375 0-.356-.816-1.166-1.343-2.063-1.343z"/><path d="m10.007 10.5c-.278 0-.545-.155-.675-.422-.181-.372-.026-.821.346-1.002l9.244-4.5c.234-.114.507-.099.726.039.219.136.352.377.352.635v4c0 .414-.336.75-.75.75s-.75-.336-.75-.75v-2.801l-8.166 3.975c-.105.052-.217.076-.327.076z"/><path d="m9.25 20c-.125 0-.25-.03-.366-.096l-8.5-4.75c-.237-.132-.384-.383-.384-.654v-9.25c0-.258.133-.499.353-.636.218-.138.493-.153.726-.039l9.244 4.5c.373.181.527.63.346 1.002-.182.373-.632.525-1.002.346l-8.167-3.974v7.61l8.116 4.536c.362.201.491.658.289 1.021-.137.245-.393.384-.655.384z"/><path d="m.75 6c-.277 0-.544-.155-.674-.422-.181-.372-.026-.821.346-1.002l9.244-4.5c.207-.101.449-.101.656 0l9.256 4.5c.373.181.527.63.346 1.002s-.629.529-1.002.346l-8.928-4.34-8.916 4.34c-.105.052-.217.076-.328.076z"/><path d="m5.25 11.99c-.414 0-.75-.336-.75-.75v-3.8c0-.283.16-.542.413-.67l9.09-4.581c.369-.186.82-.038 1.007.333.186.37.038.821-.333 1.007l-8.677 4.373v3.338c0 .414-.336.75-.75.75z"/></svg>');
printf('</div>');
printf('</div>');
}
add_action('woocommerce_review_order_before_submit', 'add_delivery_payment_info');
?>
<div class="inpage-form" data-product-id="<?php echo $productId; ?>">
<div class="inpage-form__form-card">
<h4>Modulo d’ordine</h4>
<div class="inpage-form__total">
<span class="inpage-form__regular-price"><?php formatPrice($initialVariation['regular_price']); ?></span>
<span class="inpage-form__price"><?php formatPrice($initialVariation['price']); ?></span>
</div>
<!--<div class="inpage-form__countdown">
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512"
xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="m6.5 19h-2c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h2c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m22.75 19h-1.25c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h.835l.674-3.592c-.009-1.838-1.579-3.408-3.509-3.408h-3.283l-1.591 7h2.874c.276 0 .5.224.5.5s-.224.5-.5.5h-3.5c-.152 0-.296-.069-.391-.188-.095-.118-.131-.274-.097-.422l1.818-8c.052-.229.254-.39.488-.39h3.682c2.481 0 4.5 2.019 4.5 4.5l-.759 4.092c-.044.237-.25.408-.491.408z"/>
<path d="m19.5 21c-1.378 0-2.5-1.121-2.5-2.5s1.122-2.5 2.5-2.5 2.5 1.121 2.5 2.5-1.122 2.5-2.5 2.5zm0-4c-.827 0-1.5.673-1.5 1.5s.673 1.5 1.5 1.5 1.5-.673 1.5-1.5-.673-1.5-1.5-1.5z"/>
<path d="m8.5 21c-1.378 0-2.5-1.121-2.5-2.5s1.122-2.5 2.5-2.5 2.5 1.121 2.5 2.5-1.122 2.5-2.5 2.5zm0-4c-.827 0-1.5.673-1.5 1.5s.673 1.5 1.5 1.5 1.5-.673 1.5-1.5-.673-1.5-1.5-1.5z"/>
<path d="m6.5 10h-4c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h4c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m6.5 13h-5c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h5c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m6.5 16h-6c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h6c.276 0 .5.224.5.5s-.224.5-.5.5z"/>
<path d="m14 19h-3.5c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h3.101l2.272-10h-11.373c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h12c.152 0 .296.069.391.188.095.118.131.274.097.422l-2.5 11c-.052.229-.255.39-.488.39z"/>
</svg>
<div>
<div class="inpage-form__countdown__title">Affrettati con l'acquisto</div>
<div class="inpage-form__countdown__description">Se ordini entro
<time class="inpage-form__countdown_hook">30:00</time>
minuti riceverai <strong><?php //echo business_day(2); ?></strong></div>
<div class="inpage-form__countdown__description">Se ordini entro
<time class="inpage-form__countdowner_hook">30:00</time>
minuti riceverai <strong><? //php echo business_day(2); ?></strong></div>
</div>
</div>-->
<?php if(count($variations) > 1): ?>
<ul class="inpage-form__options">
<?php foreach ($variations as $variation) :
$singlePrice = $variation['price'] / (float) $variation['quantity'];
?>
<li class="inpage-form__option <?php echo $variation['highlight'] ? 'inpage-form__option-highlight' : ''; ?>">
<input
type="radio"
name="quantity"
id="option-<?php echo $variation['id']; ?>" value="<?php echo $variation['id']; ?>"
data-regular-price="<?php echo $variation['regular_price']; ?>"
data-price="<?php echo $variation['price']; ?>"
/>
<?php if ($variation['highlight']) { ?>
<div class="inpage-form__option-top" <?php echo $variation['highlight_color'] ? 'style="background-color:'. $variation['highlight_color'].'"' : ''; ?>>
<?php echo $variation['highlight']; ?>
</div>
<?php } ?>
<label for="option-<?php echo $variation['id']; ?>">
<span class="inpage-form__quantity"><?php echo $variation['quantity']; ?><small>x</small></span>
<span class="inpage-form__option-main">
<span class="inpage-form__single-price"><?php formatPrice($singlePrice); ?></span>
<span class="inpage-form__quantity-info">a pezzo</span>
</span>
</label>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="inpage-form__checkout">
<form name="checkout" method="post" class="checkout woocommerce-checkout"
action="<?php echo esc_url(wc_get_checkout_url()); ?>" enctype="multipart/form-data">
<div class="woocommerce-billing-fields__field-wrapper">
<p class="form-row form-row-wide validate-required validate-email" id="billing_email_field"
data-priority="110">
<input type="email" class="input-text" name="billing_email" id="billing_email"
placeholder="Indirizzo email " value="" autocomplete="email username"/>
<label for="billing_email" class="">Indirizzo email</label>
</p>
<p class="form-row form-row-wide validate-required validate-phone" id="billing_phone_field"
data-priority="100">
<input type="tel" class="input-text "
name="billing_phone" id="billing_phone"
placeholder="Telefono" value=""
autocomplete="tel"/>
<label for="billing_phone" class="">Telefono</label>
</p>
<div class="inpage-form__form-row-online">
<p class="form-row form-row-first validate-required" id="billing_first_name_field"
data-priority="10">
<input type="text" class="input-text " name="billing_first_name" id="billing_first_name"
placeholder="Nome" value="" autocomplete="given-name"/>
<label for="billing_first_name" class="">Nome</label>
</p>
<p class="form-row form-row-last validate-required" id="billing_last_name_field"
data-priority="20">
<input type="text" class="input-text " name="billing_last_name" id="billing_last_name"
placeholder="Cognome" value="" autocomplete="family-name"/>
<label for="billing_last_name" class="">Cognome</label>
</p>
</div>
</div> 

<?php
if($options['insurance_product'] ?? false) :
$insuranceProduct = wc_get_product($options['insurance_product']);
?>
<label class="inpage-form__insurance inpage-form__extras" data-product-id="<?php echo $options['insurance_product']; ?>">
<svg id="color" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m23.491 1.826-5.25-1.786c-.156-.054-.326-.054-.482 0l-5.25 1.786c-.305.103-.509.388-.509.71v4.018c0 4.904 5.474 7.288 5.707 7.387.094.039.193.059.293.059s.199-.02.293-.06c.233-.099 5.707-2.482 5.707-7.386v-4.018c0-.322-.204-.607-.509-.71z" fill="#4caf50"/><path d="m21.286 5.618-2.75 3.5c-.168.214-.417.351-.688.377l-.098.005c-.237 0-.469-.084-.65-.241l-1.75-1.5c-.42-.359-.469-.991-.108-1.41.359-.419.991-.467 1.409-.108l.958.821 2.105-2.679c.341-.434.969-.511 1.404-.168.434.34.51.969.168 1.403z" fill="#fff"/><path d="m18 0h-.019c-.075.002-.15.015-.222.04l-5.25 1.786c-.305.103-.509.388-.509.71v4.018c0 4.904 5.474 7.288 5.707 7.387.094.039.193.059.293.059v-4.532c-.05.013-.101.022-.152.027l-.098.005c-.237 0-.469-.084-.65-.241l-1.75-1.5c-.42-.359-.469-.991-.108-1.41.197-.23.477-.349.759-.349.23 0 .462.079.649.24l.958.821.392-.498z" fill="#429846"/><path d="m16.001 6c-.282 0-.562.118-.76.349-.36.419-.312 1.051.108 1.41l1.75 1.5c.182.157.414.241.651.241l.098-.005c.051-.005.102-.014.152-.027v-2.905l-.392.498-.958-.82c-.188-.162-.419-.241-.649-.241z" fill="#dedede"/><path d="m22 17.5c-2 0-6 2.531-8 2.531s-4.25-1.531-4.25-1.531 2.693.5 4.25.5 2-.531 2-1.25c0-1.75-2.973-2.022-4.476-2.25-1.477-.822-3.037-1.333-5.481-1.54-.015.142-.037.284-.077.425l-2.009 7.08c2.275 1.036 6.986 2.535 9.043 2.535 3 0 11-4 11-5s-1-1.5-2-1.5z" fill="#ffcc80"/><path d="m3.5 22h-2.75c-.414 0-.75-.336-.75-.75v-8.5c0-.414.336-.75.75-.75 3.505 0 5.138 1.216 5.205 1.268.242.185.349.498.27.792l-2 7.386c-.089.327-.386.554-.725.554z" fill="#2196f3"/><path d="m22 17.5c-2 0-6 2.531-8 2.531s-4.25-1.531-4.25-1.531l-4.472-.944-1.053 3.89c-.011.042-.026.081-.044.12 2.348 1.028 6.828 2.434 8.819 2.434 3 0 11-4 11-5s-1-1.5-2-1.5z" fill="#deb26f"/><path d="m0 16.442v4.808c0 .414.336.75.75.75h2.75c.296 0 .56-.173.681-.435.018-.038.032-.078.044-.12l1.053-3.89z" fill="#1d83d4"/></svg>
<div class="inpage-form__insurance__wrapper">
<?php
if($insuranceProduct->get_regular_price() !== $insuranceProduct->get_price()) {
printf('<div class="inpage-form__insurance__title">Assicura il tuo pacchetto a soli <del>%s</del> %s</div>', wc_price($insuranceProduct->get_regular_price()), wc_price($insuranceProduct->get_price()));
} else {
printf('<div class="inpage-form__insurance__title">Assicura il tuo pacchetto a soli %s</div>', wc_price($insuranceProduct->get_price()));
}
?>
<div class="inpage-form__insurance__description">Se il prodotto nella confezione è danneggiato, te ne invieremo uno nuovo senza alcuna domanda.</div>
</div>
<input type="checkbox" name="insurance_enable">
</label>
<?php
endif
?>
<?php
if($options['gift_product'] ?? false) :
$giftProduct = wc_get_product($options['gift_product']);
?>
<label class="inpage-form__gift inpage-form__extras" data-product-id="<?php echo $options['gift_product']; ?>">
<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g fill="#fbe77b"><path d="m214.374 64.52s-64.52-64.52-139.447-64.52c-43.707 0-60.358 29.138-60.358 58.276s17.691 58.276 49.951 58.276h149.854z"/><path d="m214.374 64.52s-64.52-64.52-139.447-64.52c-43.707 0-60.358 29.138-60.358 58.276s17.691 58.276 49.951 58.276h149.854z"/><path d="m297.626 64.52s64.52-64.52 139.447-64.52c43.707 0 60.358 29.138 60.358 58.276s-17.691 58.276-49.951 58.276h-149.854z"/></g><path d="m492 199.805h-472c-11.046 0-20-8.954-20-20v-43.252c0-11.046 8.954-20 20-20h472c11.046 0 20 8.954 20 20v43.252c0 11.046-8.954 20-20 20z" fill="#fb636f"/><path d="m484.943 116.553v83.252h6.453c11.379 0 20.604-9.225 20.604-20.604v-42.045c0-11.379-9.225-20.604-20.604-20.604h-6.453z" fill="#fa4954"/><path d="m193.561 116.553h124.878v83.252h-124.878z" fill="#fbe77b"/><path d="m464.943 512h-417.886c-11.046 0-20-8.954-20-20v-292.195h457.886v292.195c0 11.046-8.954 20-20 20z" fill="#fb636f"/><path d="m27.057 199.805h457.886v24.976h-457.886z" fill="#fa4954"/><path d="m214.374 199.805h83.252v312.195h-83.252z" fill="#fbe77b"/><path d="m214.374 199.805h83.252v24.976h-83.252z" fill="#fcdd2e"/><path d="m326.764 95.74c-4.333 0-8.045-2.65-9.611-6.416 2.685-.986 5.58-1.951 8.585-2.798 4.107-1.158 6.498-5.426 5.341-9.533s-5.425-6.499-9.533-5.341c-1.773.5-3.505 1.035-5.189 1.589v-24.848c-11.859 9.256-18.732 16.127-18.732 16.127v52.033h149.855c17.376 0 30.516-8.46 38.951-20.813z" fill="#fcdd2e"/><path d="m195.642 48.393v24.848c-1.683-.554-3.416-1.089-5.189-1.589-4.104-1.157-8.375 1.233-9.533 5.341-1.157 4.107 1.233 8.375 5.341 9.533 2.998.845 5.895 1.812 8.584 2.8-1.566 3.765-5.278 6.413-9.61 6.413h-159.666c8.435 12.353 21.575 20.813 38.951 20.813h149.854v-52.032s-6.873-6.871-18.732-16.127z" fill="#fcdd2e"/><path d="m297.626 116.553h-83.252v-52.602c0-7.732 6.268-14 14-14h55.252c7.732 0 14 6.268 14 14z" fill="#fbe77b"/><path d="m214.374 95.74h83.252v20.813h-83.252z" fill="#fcdd2e"/></svg>
<div class="inpage-form__gift__wrapper">
<div class="inpage-form__gift__title">Abbiamo un regalo per te!</div>
<?php
if($giftProduct->get_regular_price() !== $giftProduct->get_price()) {
printf('<div class="inpage-form__gift__description">Prodotto esclusivo per te a solo <del>%s</del> <strong>%s</strong></div>', wc_price($giftProduct->get_regular_price()), wc_price($giftProduct->get_price()));
} else {
printf('<div class="inpage-form__gift__description">Prodotto esclusivo per te a solo <strong>%s</strong></div>', wc_price($giftProduct->get_price()));
}
?>
</div>
<input type="checkbox" name="gift_enable">
<div type="button" class="inpage-form__gift__btn">
Aggiungi
</div>
</label>
<?php
endif
?>
<h3>Metodo di pagamento</h3>
<div id="order_review" class="woocommerce-checkout-review-order">
<?php woocommerce_checkout_payment(); ?>
</div>
</form>
</div>
</div>
<!--    --><?php //WC()->checkout()->checkout_form_billing(); ?>
</div>

最新更新