Coder Social home page Coder Social logo

Comments (2)

crftwrk avatar crftwrk commented on May 25, 2024

Thank you for reporting, this is a known issue. Offcanvas uses same hook for alerts like the account page. In case if you edit something in your account, it can be that an alert is shown in offcanvas instead in the top of the page. The alert in offcanvas is neccessary for feedback if you do a wrong login or registration in offcanvas.

For us so far, the benefit of using offcanvas login and dashboard is much more higher than the bug with the alerts on account page. We are planning to general refactor the WooCommerce alerts handling in bootScore, but this has a minor priority.

Using default WC login

You can hotfix that very easy by using the default WooCommerce login and dashboard instead of offcanvas.

Delete user offcanvas

Open header.php in your child, search for following snippet and delete it:

<!-- offcanvas user -->
<div class="offcanvas offcanvas-start" tabindex="-1" id="offcanvas-user">
  <div class="offcanvas-header bg-light">
    <span class="h5 mb-0"><?php esc_html_e('Account', 'bootscore'); ?></span>
    <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body">
    <div class="my-offcancas-account">
      <?php include get_template_directory() . '/woocommerce/myaccount/my-account-offcanvas.php'; ?>
    </div>
  </div>
</div>

Change the user <button> to an <a> and link it to the my-account page.

Search in header.php for the user offcanvas toggler:

<!-- User Toggler -->
<button class="btn btn-outline-secondary ms-1 ms-md-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvas-user" aria-controls="offcanvas-user">
  <i class="fas fa-user"></i>
</button>

Replace toggler with this:

<!-- User Toggler -->
<a href="[my-account]" class="btn btn-outline-secondary ms-1 ms-md-2">
  <i class="fas fa-user"></i>
</a>

from bootscore.

crftwrk avatar crftwrk commented on May 25, 2024

Another idea is to generally remove alerts in offcanvas and do a redirect to my-account.php if login failed instead.
Found something here: woocommerce/woocommerce#11864

// Redirect to my-account if offcanvas login failed
add_action( 'woocommerce_login_failed', 'redirect_on_login_failed' , 10, 0 );
function redirect_on_login_failed() : void {
  // Logout user doesn't have session, we need this to display notices
  if ( ! WC()->session->has_session() ) {
    WC()->session->set_customer_session_cookie( true );
  }
  wp_redirect( wp_validate_redirect( wc_get_page_permalink( 'myaccount' ) ) );
    exit;
}

// Redirect to home on logout (optional)
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
  wp_redirect( home_url() );
  exit();
}

If user login failed in checkout page, it redirects to myaccount as well.

ToDo

  • Remove hook in my-account-offcanvas.php
  • Remove jQuery to keep offcanvas open in woocommerce/js/woocommerce.js
  • Add redirect snippet to woocommerce-functions.php

from bootscore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.