Articles On Web Design

List all Customer Coupons in Woocommerce

List all Customer Coupons in Woocommerce

Recently I was tasked with figuring out how to do something that I figured would be easy but was deceptively hard – displaying all the coupons for a customer in woocommerce. A client wanted to show a user all their coupons, and surprisingly this wasn’t built into woocomerce already. To solve the problem, I created a custom page template and ran a query on the wp_postmeta table to get the ids of all of the coupons that were linked to the customer’s email. Then I ran a WP Query to get the posts and used the get_post_meta function to display the various coupon meta fields and build the data. Here is an overview of the technique using generic information.   Get The Current User Data global $current_user, $woocommerce;  //get current user and woocommerce global variables get_currentuserinfo(); // get current logged in user info           $current_user = wp_get_current_user();   // grab the logged in user         $user_id = $current_user->ID;           // grab the logged in users id         $email = $current_user->user_email;    // grab the logged in user email   Run a query on the meta table, targeting the coupons linked to the customer’s email and create an array of the ids returned // Run a query on the postmeta table to get the id of every coupon that has the email in the customer_email restrictions $couponlist = $wpdb->get_results("SELECT `wp_postmeta`.`post_id` FROM `wp_postmeta` WHERE `wp_postmeta`.`meta_key` LIKE 'customer_email' AND `wp_postmeta`.`meta_value` LIKE '%".$email."%'"); $couponarrayfinal = array( );  //Create an array of the ids so we can use wp_query to... read more
Woocommerce Search Orders By Item or Sku Plugin

Woocommerce Search Orders By Item or Sku Plugin

A while back a client, by which I mean every client I’ve ever had with a woocommerce store on their site, asked me if they can search through their orders to find all orders that contain a certain item. As my introduction to Woocommerce was a little over a year ago, I knew the functionality wasn’t there but I wasn’t sure how to add it. Being the good forward thinker that I am, I put it on my “Deal with this eventually list” and proceeded to move on to issues that had deadlines and that clients were actually paying me to fix for them. In a few moment of downtime the other week, I decided to revisit the issue. Much to my delight, I found some definitive answers on how to make this happen. This recent post on Stack Exchange contained code and a solution cobbled together by 3 or 4 different users. http://stackoverflow.com/questions/28063920/search-by-order-item-sku-or-id-in-woocommerce-orders-admin-page I grabbed it, tested it on a few of my test sites, and gleefully found that it added the exact ability so many of my clients had been looking for. Searching for these answers before last month turned up many scarce results, so I decided to wrap the code in an easy to install plugin and throw it out there for anyone who might need it. Please be aware of a few things. I did not write this code, merely compiled the solution from the stack exchange thread into a plugin so all you have to do is install and not worry about modifying your functions file in your theme. Code for this plugin was... read more
Woocommerce CSV Export HTTP POST

Woocommerce CSV Export HTTP POST

I was recently tasked with writing a script to export the data from a woocommerce database, rearrange it, and email it to a warehousing partner automatically. The first part was pretty easy – writing the script, rearranging the sample data, and emailing it automatically when the script was run. The second part was a bit more complex. The client had the GNU licensed CSV Customer/Order Export extension for Woocommerce. Unfortunately, it wasn’t working as expected. The client  had already purchased a support license, but I hadn’t heard back from the support techs yet and was running far too close to deadline for my own comfort. The extension is set up to export to FTP or HTTP POST automatically and I decided to integrate that and accept the file it exports in the post instead of just using SQL to dig into the complex database structures and grab the data (more on that in another post). There was only one problem, it doesn’t actually submit a file with the HTTP POST option. The Solution Since I solved the problem, I figured I would share the solution for any other coder having the same issue. I’ve also asked support staff to update the documentation, as knowing one simple fact would have saved me HOURS of work. The HTTP POST option from CSV Customer Order Export sends a stream of CSV formatted data, but not an actual CSV file. I had built a script that was capable of taking a submitted file and then running code on it to reorganize it, grab the correct data, upload into an SQL database and then... read more
Website or Facebook page?

Website or Facebook page?

I’m going to reveal my bias right up front for this issue I think that a Facebook Page is an essential part of any marketing strategy or online presence, but it doesn’t provide the same quality of presence that a website does. I’ve designed many Facebook pages and manage many different versions of the same think of different social networks like Google Plus.  While a Facebook page is great for many uses and can provide a lot of exposure, it doesn’t replace what a website does. Here are a few reasons why: The Theoretical Mexican Restaurant Let’s look at this from the standpoint of a Mexican Restaurant that knows they need a web presence. I choose a mexican restaurant as an example because they are fairly common in most cities, have competition from many other establishments, and they stand to gain or lose customers based on their online presence. This is the same for any type of business. A Quick Search Online – When a potential customer for the restaurant decides they want Mexican food, they go online. In the search results, a website stands out much more than a Facebook link, if the Facebook link even shows up. Search engines rank entries based on the information they can be sure of, and Facebook doesn’t always provide that information to the search engine. So, a search for Mexican Food Oxford, Ms doesn’t always bring up the Facebook page. While many search engines are trying to provide more information in every search, having that link to a website does much more to make you stand out. Reliability of Information –... read more

Articles On Web Design

From time to time I write articles on web design, thoughts on how to solve coding issues, or reviews of options that may help customers in the future. You'll find all of those here.

About Me

My name is John Arcadian. I'm the driving force behind Bee Zen Web Design. I'm a web developer, designer, writer of role playing game books, and a builder of sonic screwdrivers. If you want to now more about me, check out my personal site http://johnarcadian.com