Jump to content

moein

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by moein

  1. for security issue, use this $location = $_SERVER['HTTP_REFERER']; wp_safe_redirect($location);
  2. thanks for the reply I have no knowledge of programming, and with a great deal of effort I obtained these codes Yes it's about WordPress My theme uses a login pop-up Modal [this cod: mf_get_option('login_reg_popup')] , I use that pop-up instead of a redirect to the login page The following code is for displaying popup login templates when you click the checkout button <?php function woocommerce_button_proceed_to_checkout() { $checkout_url = WC()->cart->get_checkout_url(); ?> <div <?php echo mf_get_option( 'login_reg_popup' ) ? 'data-toggle="modal" data-target="#login-modal"' : null; ?>> <a class="checkout-button button alt wc-forward" href="<?php echo ! mf_get_option( 'login_reg_popup' ) ? wc_get_page_permalink( 'myaccount' ) : '#'; ?>" class="checkout-button button alt wc-forward"><?php _e( 'اقدام به پرداخت', 'woocommerce' ); ?></a> <?php } I would like the following terms to be done by user clicking on that checkout button 1. If not logged-in and it was in the cart page then display popup and login=> redirect to the checkout page 2. If logged-in and it was in the cart page then after clicking the checkout button=> redirect to the checkout page 3. Except cart page, the user logged in everywhere site => redirect to the current page user I hope you guide me
  3. Hello I use this code to display popup login when user to clicked on a "proceed to checkout" button in the cart page (woocomerce) <?php function woocommerce_button_proceed_to_checkout() { $checkout_url = WC()->cart->get_checkout_url(); ?> <div <?php echo mf_get_option( 'login_reg_popup' ) ? 'data-toggle="modal" data-target="#login-modal"' : null; ?>> <a class="checkout-button button alt wc-forward" href="<?php echo ! mf_get_option( 'login_reg_popup' ) ? wc_get_page_permalink( 'myaccount' ) : '#'; ?>" class="checkout-button button alt wc-forward"><?php _e( 'اقدام به پرداخت', 'woocommerce' ); ?></a> <?php } But after login, I want the user to be redirected to the "checkout" page if it is on the cart page Otherwise redirect to your current page wherever you are logged in I found the following code but I couldn't put it in the code above Thank you for helping me with your kindness <?php //redirect to your "current" page wp_redirect( $_SERVER["HTTP_REFERER"] ); // redirect to the "checkout" page function wpse_131562_redirect() { if (! is_user_logged_in() && (is_woocommerce() || is_cart()) ) { // feel free to customize the following line to suit your needs wp_redirect(site_url('checkout/')); exit; } } add_action('template_redirect', 'wpse_131562_redirect');
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.