[SOLVED] WordPress/WooCommerce Reset Password form not working

I am not sure when this started occurring, but recently a few of my users complained that they are unable to change their passwords. They click on the "Lost Password" link. They receive the email with the link to reset the password.

Upon clicking on the link, they are redirected to "https://…./my-account/lost-password/?show-reset-form=true". However, the Reset Password form does not show up. Instead, they receive the original Lost Password screen prompting them to enter username/email so the Lost Password email can be sent to them. 

So the users are in this circular loop. They are unable to change the password.

Looking at the relevant code (https://github.com/woocommerce/woocommerce/blob/a3ec0bf85aa6a55ed3241fc2a30a397e4b1273dc/includes/shortcodes/class-wc-shortcode-my-account.php#L215), it seems that the "wp-resetpass-" cookie is not being set. 

Ask your hosting provider if somehow they are caching the "my-account" and "lost-password" pages. If they are, that can explain this behaviour. Atleast, that was the case with me. Once those URL's were excluded from cache, the Reset Password" form showed up successfully. 

Have you experienced this issue before? What did you find?

How to move the Archive Text in Genesis

For a while, I have struggled with how to remove or change location of the Archive Intro Text in a Genesis-based theme. Essentially, the idea is to move the Archive Intro Text towards the bottom of the page mostly for SEO purposes.

When I asked the questions on the StudioPress forums, I did not receive a satisfactory answer. So I did what most coders do: hack it till you discover how to do this way. Worry not, because this is not a hack. It is actually the recommended way to make a change like this.

Here is the code

The first 4 lines simply unhook the actions responsible for showing the Archive Intro Text at its default position. This will make sure the Archive Intro Text does not show up in its usual location.

The rest of the code moves the Archive Intro Text down to the bottom of the page, by hooking on to the “woocommerce_after_shop_loop” action. The trick is to get the relevant parameters passed to the function that eventually displays the Archive Intro Text.

This example is limited only to moving the Archive Intro Text. You will have to extend it to display the Archive Headline to the bottom.

Do let me know if you have any questions!

How to Setup Algolia Search on WordPress with Genesis Theme

For those of you new to Algolia, this is another Instant Search solution for WordPress search. It is a 3rd party solution. The plugin is Free. The service is based on the free plugin on the client side communicating with the Algolia servers to retrieve search results for users.

The Algolia setup is very simple. You download the plugin from https://github.com/algolia/algoliasearch-wordpress. Install the plugin manually via your WordPress Admin. Create a new account on www.algolia.com.

For some reason, my drop down box containing the Search Results was not showing. It would only happen when using a Genesis theme. For other themes (I verified it worked with Storefront), it worked just fine. I posted in the StudioPress forums, but no luck. I inspected the Chrome Inspect Console but saw no JS errors.

I even tried disabling one plugin at a time, trying to figure out a possible conflict. No luck there either.

I decided to seek the help of Algolia’s support team. Sylvain Utard, the VP of Algolia Search came to my rescue. After a few experiements and emails back and forth, he figured out the issue. The issue was CSS related.

From my understanding, the Search Form overflow property was not visible by default in Genesis. The drop down for Algolia Search Results was always there, just invisible!

Here is the fix
.search-form {
overflow: visible !important;
}

Voila! That CSS change did the trick.

WooCommerce: Replace “Add To Cart” with “Ask” Form for Custom Products

When you Google the phrase “replace Add to Cart WooCommerce” (or any variants thereof), there are a lot of SERP’s suggesting the same way of hiding/not displaying the Add To Cart button. The idea is to remove the “woocommerce_template_single_add_to_cart” action.

Replace “Add to Cart” for Custom Products

However, in my case, I wanted to do this for only certain specific products. I have products that are marked as “Custom”, i.e. not stocked products. These are products that can be customized as per the customer/client. They usually take 6-8 weeks from order to delivery. The idea for the landing pages for these “Custom” products is not for them to make the purchase outright, but get them to contact the store owner. This way, the process of designing the custom product can be taken offline.

How to Designate a Product as “Custom”

The first step is to identify the products as “Custom” in WooCommerce. Following this guide by Remy Corson, I added a Checkbox under the General tab in the Product Edit Screen. When this Checkbox is checked, it means that the Product is “Custom”.

"Custom" product
“Custom” product

As you can see in the image above, this product is defined as “Custom”.

Next up, we have to hook into the correct action for marking all “Custom” products as not being allowed for Purchase. We will use the is_purchaseable() hook for that purpose.

Alternative CTA for “Custom” Products

I wanted a form to take the place of the “Add To Cart” button. In my case, I use Contact Form 7 for my forms. I just added a small form specifically for the purpose of this CTA. The visitors will see this form in place of the Add to Cart button. The store owner receives an email containing the lead.

We are simply checking if the Product is “Custom”. If it is “Custom”, we will set it as being non-purchaseable. This will hide the “Add To Cart” button for such “Custom” products.

Full Code Listing

Here is the full code. Notice that 2 other custom fields were added. You do not need those, so you can easily delete the relevant lines of code.

Questions/Comments? Type away in the comments below.

How to Add JavaScript to your theme

From the last WordPress meetup, we discussed How to add javascript to your theme

Inside functions.php, hook into the wp-enqueue_scripts hook

add_action( 'wp_enqueue_scripts', 'wpmia_load-javascript_files');

function wpmia_load_javascript_files() {

wp_register_script( 'info-caroufredsel', get_template_directory_uri() . ' jquery.carouFredSel-5.5.0-packed.js', array ('jquery', '5.5.0', true);

...

...

wp_enqueue_script( 'info-carousel-instance' );

 

if ( is_front_page() ) {

wp_enqueue_script('home-page-main-flex-silder');

} 

}