Category Archives: PHP

Woocommerce snippets

For SINGLE PRODUCTS– Skip Cart WooCommerce shopping cart altogether and send your buyers straight to the checkout page and Increase Conversions Instantly! The more steps you put your buyer through, the lower your conversions. Here are the 2 code snippets:

WooCommerce Skip Cart Code

This snippet allows the user to skip to the cart directly.

 

Change WooCommerce Add to Cart Button Text to BUY NOW!

 

Both snippet will work on WooCommerce 4 and newer.

Once you add these codes to your WooCommerce store, you’ll see that your customers will be redirected to the checkout once they click on the Buy Now button.

 

Adding ACF Options page via a plugin

Because of the possibility of plugin loading order error, it is best to use the init hook to search for acf existence and adding the options page. i.e:

 

 

Max Mega Menu – adding a custom divider

I wanted to add a “|” character in-between elements but the only option in Max Mega Menu (MMM) is to enable a divider or not but not specify a custom divider – it only uses the border-right/left settings.

Their support suggested this but stated it could cause icon alignment issues – under custom CSS in MMM:

I ended up using a javascript hack to get it done:

 

 

Various onFocus animations using Fluent Forms

*Note – I’ve noticed the dark theme on this website can make the onFocus effects harder to see. If that is the case, try viewing this blog post with the “light” theme.

Fluent Forms onFocus Examples

To be used with Text or TextArea type inputs in Fluent Form. Every example needsto add the class “animated_form_element” under the Advanced Options for each of the text/textarea’  “Element Class” field such as below:

For each set of animations, hit the reveal button to show the code that has to be added to your Fluent Form’s Custom CSS/JS sections. That section can be found under “Settings & Integrations tab -> Custom CSS/JS”

Underline

Drop In Underline Example:

dropin_underline

Left To Right

Adding on focus animations to a Fluent Form

Fluent Forms is a popular WordPress plugin that allows you to make forms easily. One thing I didn’t like is that there is no onFocus options for animations etc. With inspiration from a different post about hyper link hover animations ( found here ) for Divi menu modules, I added on focus animation for my Fluent Form. I created this small tutorial to show how I did it.

Here is an example of what the outcome looks like:

Fluent Forms animated on focus

To do this, you first have to add the class “animated_form_element” under the Advanced Options for each of the text/textarea’  “Element Class” field such as below:

 

Next, we need to add some custom css and javascript to our form. We add it by going to the form’s  “Settings & Integrations tab -> Custom CSS/JS” section.

For the CSS, it really depends on the look you are going for but for this example I wanted a bottom border to be shown on the input/textarea field regardless if it has focus or not. I also removed the default border radius on the input field as well. Here is the customer css to accomplish those things.

I use !important to be sure it overrides Fluent Forms default styles.

Next, let’s add the styles needed for the actual animation itself as well as modifying how the “This field is required.” is shown:

The error message for “This field is required” aka .text-danger is made switched to absolute  positioning and in this case has been set 5px from the bottom of the input fields container. Really, this could be different based on how you want the field to show on the form. You could use top instead for example. However, the .text-danger must be made absolute as we need it out of the document flow so it won’t create visual bugs with extra space in between the inputs border bottom  and the border bottom that is used to create the animation.

Finally, we need to add some custom javascript to the form as well:

 

And that’s it for this example really.

You may notice I named the actual animation class name “animatedStyleName” which is generic. I did this because really you could take many of the different animations listed in the divi-menu-effects.css you can download from this site and replace the rules of animatedStyleName to do different types of animations. You have to subscribe to his newsletter in order to get the previously mentioned .css file that has the different animations. Some of the animation examples on that site require more work than what I described but I plan on writing an extension of this tutorial if it seems people might want it.

Can download the Fluent Form export example here . You may have to right click -> “save link as” for it to work.

Live example:

contactus