Managing WooCommerce With The YITH Frontend Manager For WooCommerce Plugin

If managing your WooCommerce Store isn’t time consuming enough, imagine having to train new personnel on what they can do or should do when they access your Website’s back-end. YITH saw there was a need to allow collaborators and even store managers to be able to add and edit products without ever having access to the back-end. Say hello to the “YITH Frontend Manager For WooCommerce” plugin.

YITH Frontend Manager For WooCommerce Plugin

The YITH Frontend Manager For WooCommerce plugin allows you to:

  • Enable Front-End Shop Management for Your Site
    It will provide a Shop manager with an interactive, feature-rich dashboard allowing to update many aspects of your WooCommerce Store.
  • Restrict Shop Manager’s Back-End Access
    Prevent All Shop Managers From Having Access To The Site Back-end. Your WooCommerce Store will be completely managed from the Front-End of your Website.
  • Choose Shop Sections To Enable In The Front-End
    That’s right, you can easily enable or disable which WooCommerce Modules are displayed to Shop Managers. Modules include Coupons, Dashboard, Logout, Orders, Products and Reports.
  • Manage Unauthorized Access
    Keep those without access out of your Website. Show them you mean business by displaying a customizable error message.
  • Enable WordPress Admin Bar
    Enable the WordPress Admin Bar for Shop Managers so they can quickly get to the Front-End Dashboard.
  • Edit The Endpoints Of Each SectionChange the Endpoints/Urls to specific sections. For example, the default endpoint to manage Coupons is /coupon/. This option would allow you to change it to something like /coupon-management/.
  • Choose The Skin To Be Used For The Dashboard

The YITH Frontend Manager For WooCommerce Plugin In Combination With YITH Multi Vendor Can

  • Enable All Vendors To Access The Front-End Dashboard
  • Choose Which Sections To Enable For Vendors
  • Prevent All Vendors From Accessing WordPress Dashboard

YITH Frontend Manager For WooCommerce Is Developer Friendly

The YITH Frontend Manager For WooCommerce plugin is developer friendly. It contains a significant number of actions and filters that you can use to make it your own and customize it to your needs. A quick example of this can be seen below, where we are changing the capability required to view the Front-End manager to those who have upload_files permissions. In a real world application, this could be a capability registered by your own plugin.

Connecting WooCommerce To Salesforce: OAuth2 Authorization

Along with learning Typescript in the fast few months, I’ve also been putting a lot of time an energy into learning Salesforce and the Apex language. So far it has been an amazing journey and my end goal for learning Salesforce is so that I can write REST APIs that would synchronize WooCommerce and Salesforce seamlessly.

With that purpose in mind, I realized doing something like this is no easy task or something you can write in a day or two and never have to touch it again, specially since the whole ecosystem (WordPress, WooCommerce, Salesforce) gets updated very frequent and things change all the time. I’ve taken the approach of dividing this humongous task into smaller modules that would help me accomplish this in faster and more maintainable way. Being able to re-use the components and sort of add or delete them as needed is what I’m after and the first step would be to establish a connection with Salesforce so that I can begin sending my Requests.

Since this would be tied to WooCommerce on this side, I figured I would do it the WordPress/WooCommerce way so I wrote a little plugin that integrates with WooCommerce and handles the saving of all the data received from Salesforce after the initial oAuth2 authorization and saves it to the database for later use. Note that this part doesn’t include the option the revoke the token or to send the refresh token in order to obtain a new access token once the old one has expired.

Register Our Integration With WooCommerce

Let’s start coding and register our registration with WooCommerce so that it appears under the WooCommerce -> Settings -> Integrations tab. This file’s sole purpose is to help WooCommerce know this is an integration and to load other PHP Classes we are going to be using. The actual fields, settings and any other logic will be in another file.

Integration Fields Using WooCommerce’s Settings API

Everything is pretty standard, just a few fields to save our the values we get back from Salesforce.

  • SF App Consumer Key
  • SF App Consumer Secret
  • SF Login URI
  • SF oAuth2 Token
    Salesforce Token (Not actually used to communicate back and forth but it was used for obtaining the Access Token
  • SF Access Token
    Access token sent with every request for authenticating purposes.
  • SF Refresh Token
    Refresh token used whenever the Access Token needs to be renewed/refreshed
  • SF Instance URI
    All REST Request will be send to this base Uri.
  • Debug Log
    Log events such as API requests

Register Custom WordPress Endpoints

Next we register 2 endpoints which are used in the 2 step process. What follows takes care of registering two endpoints, oauth2 and oauth2-step2. It will also add some quick and dirty logic to overriding what each of these endpoints display. These templates are called authorization-step-1.php and authorization-step-2.php.

Endpoint Templates

Finally, these are the layouts for those 2 endpoints.

Download WooCommerce To Salesforce Integration: Initial Integration

WooCommerce To Salesforce Integration: Initial Integration

Prevent Product From Being Checked-Out Outside Of US

Happy New Year! Here is a quick snippet of code to prevent a product from being bought at your store from outside of the US or any other country you specify. Very useful in some situations and we use it often at work to do just that, preventing someone buying the product outside of the US or Canada.

That’s it!

WooCommerce Memberships: Useful Functions To Know

If you are are just starting to work with WooCommerce Memberships and are having to do various things programatically, here are some functions that are useful to know and will make your life and job a lot easier.

Retrieve User’s Memberships

Retrieve a list of memberships this particular user belongs to. This function will return an array of WC_Memberships_User_Membership objects or NULL if no memberships are found for the user.

Check If User Is An Active Member Of A Particular Membership Plan

Use wc_memberships_is_user_active_member() to quickly figure out if a user is an active member of any of your membership plans

Check If User Is A Member Of A Particular Membership Plan

This function is similar to the the previous one, but it doesn’t not take into consideration the “Active” status.