This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add custom column to the products admin list | |
add_filter( 'manage_edit-product_columns', 'add_custom_stock_status_column' ); | |
function add_custom_stock_status_column( $columns ) { | |
$new_columns = array(); | |
foreach ( $columns as $key => $value ) { | |
$new_columns[ $key ] = $value; | |
if ( $key === 'sku' ) { // Move after SKU column | |
$new_columns['custom_stock_status'] = 'Disponibilitate'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translate_field_with_google($text, $target_language = 'ro') { | |
//usage | |
// [translate_field_with_google({title[1]}, "ro")] where title[1] is the string, and "ro" is the lang. | |
if (!empty($text)) { | |
$api_key = 'YOUR_GOOGLE_TRANSLATE_KEY_HERE'; | |
$url = 'https://translation.googleapis.com/language/translate/v2?key=' . $api_key; | |
$data = array('q' => $text, 'target' => $target_language); | |
$options = array( | |
'http' => array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hide_shipping_when_free_is_available( $rates, $package ) { | |
$new_rates = array(); | |
$free_shipping_available = false; | |
foreach ( $rates as $rate_id => $rate ) { | |
if ( 'free_shipping' === $rate->method_id ) { | |
$new_rates[ $rate_id ] = $rate; | |
$free_shipping_available = true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cod țară | Cod județ | Cod poștal | Localitate | Cotă % | Nume taxă | Prioritate | Compusă | Livrare | Clasă de impozitare | |
---|---|---|---|---|---|---|---|---|---|---|
AT | 20.0000 | TVA | 1 | 0 | 1 | |||||
BE | 21.0000 | TVA | 1 | 0 | 1 | |||||
BG | 20.0000 | TVA | 1 | 0 | 1 | |||||
CY | 19.0000 | TVA | 1 | 0 | 1 | |||||
CZ | 21.0000 | TVA | 1 | 0 | 1 | |||||
DE | 19.0000 | TVA | 1 | 0 | 1 | |||||
DK | 25.0000 | TVA | 1 | 0 | 1 | |||||
EE | 20.0000 | TVA | 1 | 0 | 1 | |||||
ES | 21.0000 | TVA | 1 | 0 | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fix repurchase courses | |
function custom_remove_sensei_course_restriction() { | |
remove_action( 'woocommerce_add_to_cart', ['Sensei_WC', 'do_not_add_course_to_cart_if_user_taking_course'], 10 ); | |
} | |
add_action( 'init', 'custom_remove_sensei_course_restriction', 30 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (defined('WP_CLI') && WP_CLI) { | |
function convert_to_simple_products() { | |
$args = [ | |
'status' => 'publish', | |
'limit' => -1, | |
'type' => 'variable', | |
]; | |
$products = wc_get_products($args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// needs to be run via cli with: | |
// wp cleanup-all-galleries | |
if (defined('WP_CLI') && WP_CLI) { | |
class Cleanup_All_Product_Galleries_Command { | |
public function __invoke($args, $assoc_args) { | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => -1, | |
'fields' => 'ids', | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_cod_if_backorder( $available_gateways ) { | |
if ( !is_array( $available_gateways ) ) return; | |
foreach ( WC()->cart->get_cart() as $cart_item ) { | |
$product = $cart_item['data']; | |
if ( $product && $product->is_on_backorder( $cart_item['quantity'] ) ) { | |
unset( $available_gateways['cod'] ); | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Asuming you have a default setup | |
// we remove the default tabs | |
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 ); | |
// alternative (depending on setup): | |
// add_filter( 'woocommerce_product_tabs', 'my_remove_all_product_tabs', 98 ); | |
// function my_remove_all_product_tabs( $tabs ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rwk_order_notes_column( $columns ) { | |
$ordered_columns = array(); | |
foreach ( $columns as $key => $column ) { | |
$ordered_columns[ $key ] = $column; | |
if ( 'order_date' == $key ) { | |
$ordered_columns['order_notes'] = __( 'Order notes', 'woocommerce' ); | |
} | |
} |
NewerOlder