1. Go to this page and download the library: Download pfaciana/wc-helpers library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pfaciana / wc-helpers example snippets
// Most basic version, this will create a variation metabox group with two text inputs
add_action('renderwoocommerce_loaded', function () {
$panel = RWC()->variationPanel();
$group = $panel->addGroup();
$group->text( 'some_text_field_A' );
$group->text( 'some_text_field_B' );
});
// Example Product Data Panels
$args = [
'id' => 'panel_id',
'label' => "Panel Ttitle",
'conditionals' => [ 'show_if_condition', 'show_if_other_condition' ],
'wrapper_class' => '',
'priority' => 1,
'icon' => "\\f469",
];
$panel = RWC()->dataPanel( $args );
// ...or Group
$args = [
'id' => 'payment_gateway',
'hook' => 'woocommerce_product_options_general_product_data',
'priority' => 1,
];
$group = RWC()->dataGroup($args);
// Example Variation Panels/Groups
$panel = RWC()->variationPanel();
$group = RWC()->variationGroup()
// Example Addons Panels/Groups
$panel = RWC()->addonPanel();
$group = RWC()->addonGroup();
// You can add fields to either a panel or a group
$panel->datetime( [
'id' => '_start_date',
'label' => 'Start Date',
'desc_tip' => TRUE,
'description' => 'When should it start?',
] );
$group->select( [
'id' => '_some_options',
'label' => 'Select One',
'options' => [
NULL => '--- Select ---',
1 => 'Option 1',
2 => 'Option 2',
3 => 'Option 3',
],
] );
$panel->text( 'some_text_field' );
$group->hidden('some_hidden_field', [
'conditionals' => 'show_if_something',
'filter_cb' => function ( $post_id, $post, $value, $field ) {
if ( isset( $value ) ) {
update_post_meta( $post_id, $field['id'], $value );
} else {
delete_post_meta( $post_id, $field['id'] );
}
},
]);
// Support for datalists. Can be added off the RWC() instance or the panel/group instance
$color_list_id = RWC()->datalist( [ '#FF0000', '#FF9900', '#FFFF00' ] );
$group->text( '_some_color', [ 'type' => 'color', 'custom_attributes' => [ 'list' => $color_list_id ], ] );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.