PHP Classes

WLTDO WooCommerce Product Edit and Admin Module: Customize WooCommerce product edit pages

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 48 All time: 10,749 This week: 560Up
Version License PHP version Categories
product-admin 1.0.0GNU General Publi...7.2PHP 5, E-Commerce
Description 

Author

This package can customize WooCommerce product edit pages.

It provides classes to render tabs and panels that can define how product edit pages will appear.

These classes register event handlers that WooCommerce will call when it renders the product edit pages so that these classes can alter the layout of the pages.

Innovation Award
PHP Programming Innovation award nominee
November 2021
Number 2
WooCommerce is a popular e-Commerce solution that runs on top of WordPress, so it can help turn a WordPress site into a shopping site.

WooCommerce based sites can use plugins to customize their functionality in a way that matters for their users.

This package can customize WooCommerce product edit pages to improve the clarity of those pages to make them more user-friendly.

Manuel Lemos
Picture of Carlos Artur Curvelo da Matos
  Performance   Level  
Name: Carlos Artur Curvelo da ... <contact>
Classes: 22 packages by
Country: Portugal Portugal
Innovation award
Innovation award
Nominee: 14x

Winner: 2x

Details

Woo Let The Devs Out | Product Admin Module

To be used either as a standalone module or library, or as part of the WLTDO framework, this module intends to automate and ease the process of customizing WC product edit pages.

Initially, classes will take care of everything as you add new tabs and panels to product meta within the edit pages. Additionally, we are developing classes to manage and alter existent tabs and fields.

Install

The easier way of using this package is by requiring it using Composer.

Usage

In the plugin's main file, use the classes and autoload them with Composer.


use Wooletthedevsout\Product\Admin\{Tabs, Panels};
require __DIR__ . '/vendor/autoload.php';

$tabs = new Tabs('New Tab', $fields);

The class Tabs needs two parameters: the first is the name (not the slug) of the new tab, and the second an array of fields to be added. The array admits any number of fields, each one of them as a new array.

// Once the tab is created, we need to inject the panels dependency, using the method getPanel()

$tabs->getPanel();

// Also, a title can be added if you want so

$tabs->addTitle('The title');

Ok, what about the fields?

Ohh... of course. As shown, the fields and firstly passed to the Tabs instance as an array. For this moment, we cover all field types with native support by Woocommerce: text, number, textarea, checkbox, select, radio (needs a CSS fix, as the WC native function is defective for the product edit area).

So, we need an array of arrays. Each element is a field, and for each of these, the first element will be the field type:

* [{{FIELD TYPE}}, {{SLUG}}, {{LABEL}}, {{DESCRIPTION}}]*

For the select type, an additional element (another array) will include the options to be added. The same happens for the radio field, although for this latter we just cut the description, as it generates a lot of bugs within the backend. So, for the SELECT field and the RADIO field, respectivelly, we need to register like this:

* [{{FIELD TYPE}}, {{SLUG}}, {{LABEL}}, {{DESCRIPTION}}, {{ARRAY OF OPTIONS}}]* * [{{FIELD TYPE}}, {{SLUG}}, {{LABEL}}, {{ARRAY OF OPTIONS}}]*

Thus, imagine that we want two text fields, one checkbox, one select field and one radio, considering the previous code. The array to be passed would look like this:

$forms = [
	[
		'text',
		'user_message', 
		'Cool Label', 
		'Description for the tooltip with question mark.'
	],
	[
		'text', 
		'capacity', 
		'Another Label', 
		'Description for the tooltip with question mark.'
	],
	[
		'checkbox', 
		'confirm', 
		'Confirmation', 
		'Description for the tooltip with question mark.'
	],
	[
		'select', 
		'choices', 
		'Select Title', 
		'Description for the tooltip with question mark.',
		[
			'Choice 1',
			'Choice 2',
			'Choice 3'
		]
	],
	[
		'radio', 
		'choices', 
		'Select Title',
		[
			'Choice 1',
			'Choice 2'
		]
	];

FAQ

Well, this is one of the first libraries and modules for the new Woo Let The Devs Out framework. So I imagine you guys have a lot of questions. Let's try to answer some of them.

Do I need to use hooks or further implementation in order to save the meta of these new fields?

No, the Panels class is already equipped with the methods to do so.

What about validating fields?

Honestly? We are working at... we are not pretty satisfied with WC's native validation, so we should eventually come up with something more sophisticated.

Can we expect new field type (especially those not covered by the WC native API, like datetime, image, etc)?

Definitely, the point with the WLTDO framework is to provide, ultimately, an easy and OO way of extending Woocommerce. Although some implementations and extensions for WC are really well-developed, like those for payment gateways, when developing complex integrations and entire packages, they require us to be really repetitive.


  Files folder image Files (4)  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (4)  /  src  
File Role Description
  Plain text file Panels.php Class Class source
  Plain text file Tabs.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:48
This week:0
All time:10,749
This week:560Up
User Comments (1)
Thats a very great class ;-)
3 years ago (José Filipe Lopes Santos)
70%StarStarStarStar