';
if ($attachment_url = wp_get_attachment_url(get_option('WAWC_logo_selector'))) {
echo '
';
}
echo '
Home >
Login >
Details >
Payment
Home >
Login >
Details>
Payment
Home >
Login >
Details>
Payment
';
// Get WooCommerce settings
$allow_orders_without_account = ('yes' === get_option( 'woocommerce_enable_guest_checkout' )) ? true : false;
$allow_login_during_checkout = ('yes' === get_option( 'woocommerce_enable_checkout_login_reminder' )) ? true : false;
$allow_account_creation_during_checkout = ('yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' )) ? true : false;
if (!is_user_logged_in() && !$allow_orders_without_account && $allow_login_during_checkout && $allow_account_creation_during_checkout) {
echo do_shortcode('[woocommerce_my_account]');
}
if (is_plugin_active('login-with-phone-number/login-with-phonenumber.php')) {
echo '
' . do_shortcode('[idehweb_lwp]') . '
';
}
}
function WAWC_start_custom_div() {
$WAWC_page_names = get_option('WAWC_page_names', array());
$WAWC_page_links = get_option('WAWC_page_links', array());
if (!empty($WAWC_page_names)) {
echo '
';
foreach ($WAWC_page_names as $index => $WAWC_page_name) {
$WAWC_page_link = isset($WAWC_page_links[$index]) ? esc_url($WAWC_page_links[$index]) : '#';
echo '
' . esc_html($WAWC_page_name) . '';
}
echo '
';
}
echo '
';
}
// Custom function to output the closing div tag
function WAWC_end_custom_div() {
// Get the Order Bump Position value
$orderBumpPosition = get_option('WAWC_order_bump_position');
// Output different things based on the Order Bump Position
if ($orderBumpPosition === 'below_summary') {
echo do_shortcode('[WAWC_order_bump]');
}
echo '
';
woocommerce_form_field('one_time_offer', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
'label' => $orderBumpTitle,
), WC()->checkout->get_value('one_time_offer'));
echo '
'.$orderBumpDescription.'
';
echo '
';
return ob_get_clean();
}
add_shortcode('WAWC_order_bump', 'one_time_offer_shortcode');
// Add the new field to order totals - Step 3
add_action('woocommerce_cart_calculate_fees', 'add_one_time_offer_fee');
function add_one_time_offer_fee() {
$orderBumpPrice = get_option('WAWC_order_bump_price');
if ( !WC()->cart->is_empty() && WC()->session->__isset('one_time_offer') ) {
WC()->cart->add_fee('One Time Offer', $orderBumpPrice);
}
}
// Update the session value when the checkbox is clicked - Step 4
// Update the session value when the checkbox is clicked - Step 4
add_action('wp_ajax_one_time_offer', 'update_one_time_offer_session');
add_action('wp_ajax_nopriv_one_time_offer', 'update_one_time_offer_session');
function update_one_time_offer_session() {
if(isset($_POST['one_time_offer'])) {
if($_POST['one_time_offer']) {
WC()->session->set('one_time_offer', $_POST['one_time_offer']);
} else {
WC()->session->__unset('one_time_offer');
}
}
echo json_encode( WC()->session->__isset('one_time_offer') );
}