Skip to content

Instantly share code, notes, and snippets.

View add-columns-to-orders.php
<?php
add_filter( 'manage_edit-shop_order_columns', 'barcode_column', 99999 );
add_filter( 'manage_edit-page_columns', 'barcode_column', 99999 );
function barcode_column($columns) {
$new_columns = array();
foreach($columns as $key => $item){
$new_columns[$key] = $item;
if($key == 'cb'){
$new_columns['zasilkovna'] = __( 'Barcode', 'skoleni' );
View add-custom-button-to-order-action.php
<?php
// Add your custom order status action button (for orders with "processing" status)
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
// Display the button for all orders that have a 'processing' status
if ( $order->has_status( array( 'processing' ) ) ) {
// Get Order ID (compatibility all WC versions)
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
View add-column-to-order-list.php
<?php
add_filter( 'manage_edit-shop_order_columns', 'toret_barcode_column', 99999 );
function barcode_column($columns) {
$new_columns = array();
foreach($columns as $key => $item){
$new_columns[$key] = $item;
if($key == 'cb'){
$new_columns['barcode'] = __( 'Barcode', 'woocommerce' );
}
View custom-woocommerce-report.php
<?php
include_once(WC()->plugin_path().'/includes/admin/reports/class-wc-admin-report.php');
add_filter( 'woocommerce_admin_reports', 'my_custom_woocommerce_admin_reports', 10, 1 );
function my_custom_woocommerce_admin_reports( $reports ) {
$sales_by_country = array(
'sales_by_country' => array(
'title' => 'Sales By Country',
'description' => '',
'hide_title' => true,
'callback' => 'sales_by_country_callback',
View custom-setting-tab.php
<?php
class WC_Settings_Tab_Demo {
/**
* Bootstraps the class and hooks required actions & filters.
*
*/
public static function init() {
add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
add_action( 'woocommerce_settings_tabs_settings_tab_demo', __CLASS__ . '::settings_tab' );
View add-custom-product-type.php
<?php
/**
* Add new product type class
*
*/
add_action( 'init', 'toret_configurator_product_type' );
function toret_configurator_product_type(){
class WC_Product_Configurator extends WC_Product {
View add-custom-field-to-product.php
<?php
add_action( 'woocommerce_product_options_general_product_data', 'toret_custom_product_field' );
function toret_custom_product_field(){
woocommerce_wp_text_input(
array(
'id' => 'custom_product_text',
'label' => __( 'Produkt text', 'toret-skoleni' ),
'placeholder' => 'Produkt text',
View add-custom-field-to-billing-address.php
<?php
add_filter( 'woocommerce_my_account_my_address_formatted_address', 'toret_my_account_fields', 10, 3 );
function toret_my_account_fields( $fields, $customer_id, $name ) {
//$fields['position'] = get_user_meta( $customer_id, $name . '_vat_number_2', true );
$fields['position'] = 'Manager';
return $fields;
}
View move-price-file-to-plugin.php
<?php
define( 'TORETDIR', plugin_dir_path( __FILE__ ) );
add_filter( 'woocommerce_locate_template', 'toret_locate_template', 10, 3 );
function toret_locate_template( $template, $template_name, $template_path ) {
if ( $template_name == 'price.php' ){
$template = TORETDIR . 'price.php';
}
return $template;
View single-product-remove-excerpt-display-content.php
<?php
//Odebrání zkráceného výpisu
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
//Přidání contentu na místo excerptu
add_action( 'woocommerce_single_product_summary', 'toret_single_content', 20 );
function toret_single_content(){
global $post;
echo $post->post_content;
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.