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 | |
/* | |
* This function will save the value set to Minimum Quantity and Maximum Quantity options | |
* into _wc_min_qty_product and _wc_max_qty_product meta keys respectively | |
*/ | |
function wc_qty_save_product_field( $post_id ) { | |
$val_min = trim( get_post_meta( $post_id, '_wc_min_qty_product', true ) ); | |
$new_min = sanitize_text_field( $_POST['_wc_min_qty_product'] ); |
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 | |
function wc_qty_add_product_field() { | |
echo '<div class="options_group">'; | |
woocommerce_wp_text_input( | |
array( | |
'id' => '_wc_min_qty_product', | |
'label' => __( 'Minimum Quantity', 'woocommerce-max-quantity' ), | |
'placeholder' => '', | |
'desc_tip' => '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
<?php | |
/** | |
* Add a widget to the dashboard. | |
* | |
* This function is hooked into the 'wp_dashboard_setup' action below. | |
*/ | |
function wc_orders_dashboard_widgets() { | |
wp_add_dashboard_widget( | |
'wc_order_widget_id', // Widget slug. |
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
.complete, .processing, .view { | |
display: block; | |
text-indent: -9999px; | |
position: relative; | |
height: 1em; | |
width: 1em; | |
padding: 0!important; | |
height: 2em!important; | |
width: 2em; | |
} |
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 | |
/** | |
* This function include wcodw_style.css file only on dashboard. | |
*/ | |
function wc_my_enqueue_scripts_css() { | |
$screen = get_current_screen(); | |
$screen_id = $screen ? $screen->id : ''; | |
if ( $screen_id == "dashboard" ) { |
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 | |
/** | |
* Remove free product from cart when parent product is removed. | |
*/ | |
function remove_product_from_cart() { | |
// Run only in the Cart or Checkout Page | |
if( is_cart() || is_checkout() ) { |
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 | |
/** | |
* Adding button to mini cart. | |
*/ | |
function woocommerce_widget_shopping_cart_buttons_callback() { | |
echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button wc-forward x-anchor">'. esc_html__( 'Submit Order', 'woocommerce' ) .'</a>'; | |
} | |
add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_buttons_callback', 20 ); |
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 | |
function woocommerce_order_item_get_formatted_meta_data_callback( $formatted_meta ){ | |
foreach ( $formatted_meta as $key => $value ) { | |
$formatted_meta[$key]->display_value = wp_strip_all_tags( $value->display_value ); | |
} | |
return $formatted_meta; | |
} | |
add_filter( "woocommerce_order_item_get_formatted_meta_data", "woocommerce_order_item_get_formatted_meta_data_callback", 10, 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
<?php | |
/** | |
* Function to fetch all WooCommerce product ids. | |
*/ | |
function get_all_wc_products_ids() { | |
$args = array( | |
'post_type' => array( 'product' ), | |
'posts_per_page' => -1, | |
'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), // 'all' |
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 | |
function add_custom_price( $cart_object ) { | |
$cart_total = 25; // If cart total is more than this value. | |
$free_product_id = 6332; // Set price to 0 of this free product. | |
$carttotal = 0; | |
foreach ( $cart_object->cart_contents as $key => $value ) { | |
$_product = $value['data']; |
OlderNewer