Using custom JavaScript into a WordPress based Project

Hi, I am new to JavaScript and I have some experience with WordPress.

So, I am creating a website along with Woocommerce plugin and want to use some promo codes generator for the store. Since I couldn’t find any relevant plugin for it, I thought JS could do it.

I just need some references to get started. Thanks in advance.


1 Like

What type of promo codes generator did you want to embed on your site?

Hi, thanks for reaching out. I wish to use similar promo codes that up when you Google “free gift cards or promo codes.”

Since it’s New Year, I wish to give out some discount to some of my customers.

I found this similar code from a Promo Code Website. You can make some changes and get it done for your WP website. Do let me know if this works.

function makeId(length) { var text = “”; var possible = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789”; for (var i = 0; i < length; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text }

1 Like