has_custom_checkout()) {
return;
}
add_action('woocommerce_checkout_before_customer_details', function () {
global $ct_skip_checkout;
if ($ct_skip_checkout) {
return;
}
echo '
';
}, PHP_INT_MIN);
add_action('woocommerce_checkout_after_customer_details', function () {
global $ct_skip_checkout;
if ($ct_skip_checkout) {
return;
}
echo '
';
}, PHP_INT_MAX);
add_action('woocommerce_checkout_before_order_review_heading', function () {
global $ct_skip_checkout;
if ($ct_skip_checkout) {
return;
}
echo '';
}, PHP_INT_MIN);
add_action('woocommerce_checkout_after_order_review', function () {
global $ct_skip_checkout;
if ($ct_skip_checkout) {
return;
}
echo '
';
}, PHP_INT_MAX);
});
add_action(
'woocommerce_before_template_part',
function ($template_name, $template_path, $located, $args) {
if ($template_name !== 'checkout/form-checkout.php') {
return;
}
ob_start();
},
1,
4
);
add_action(
'woocommerce_after_template_part',
function ($template_name, $template_path, $located, $args) {
if ($template_name !== 'checkout/form-checkout.php') {
return;
}
$result = ob_get_clean();
global $ct_skip_checkout;
if ($this->has_custom_checkout() && ! $ct_skip_checkout) {
$form_reader = new \WP_HTML_Tag_Processor($result);
if (
$form_reader->next_tag([
'tag_name' => 'form',
'class_name' => 'woocommerce-checkout',
])
) {
$form_reader->add_class('ct-woocommerce-checkout');
$result = $form_reader->get_updated_html();
}
}
if (class_exists('Woocommerce_German_Market')) {
$search = '/' . preg_quote('', '/') . '/';
$result = preg_replace(
$search,
'
',
$result,
1
);
}
echo $result;
},
1,
4
);
add_action(
'woocommerce_before_template_part',
function ($template_name, $template_path, $located, $args) {
if ($template_name !== 'cart/cart-shipping.php') {
return;
}
ob_start();
},
1,
4
);
add_action(
'woocommerce_after_template_part',
function ($template_name, $template_path, $located, $args) {
if ($template_name !== 'cart/cart-shipping.php') {
return;
}
$result = ob_get_clean();
// drop the first column
$result = preg_replace(
'/| .+?<\/th>/',
'',
$result
);
// add option title, collspan and remove data-title
echo preg_replace(
'/( | ' . blocksy_html_tag(
'div',
[
'class' => 'ct-shipping-heading'
],
$args['package_name']
),
$result
);
},
1,
4
);
}
public function has_custom_checkout() {
$has_custom_checkout = true;
if (class_exists('FluidCheckout')) {
$has_custom_checkout = false;
}
if (class_exists('WFFN_Core')) {
$has_custom_checkout = false;
}
global $post;
if ($post && $post->post_type === 'cartflows_step') {
$has_custom_checkout = false;
}
$has_custom_checkout = apply_filters(
'blocksy:woocommerce:checkout:has-custom-markup',
$has_custom_checkout
);
return $has_custom_checkout;
}
}
|