Skip to content

Instantly share code, notes, and snippets.

View vidishpurohit's full-sized avatar

Vidish vidishpurohit

View GitHub Profile
@vidishpurohit
vidishpurohit / restore.php
Created October 5, 2020 07:52
Remove discount from variations and products woocommerce - WooExtend
<?php
require_once('wp-load.php');
global $wpdb;
$str = "SELECT post_id, meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key = '_regular_price'";
$arrRes = $wpdb->get_results($str);
foreach ($arrRes as $key => $value) {
update_post_meta( $value->post_id, '_price', $value->meta_value);
@vidishpurohit
vidishpurohit / gist:aea5e302553f90922a810daf3ad5dea7
Created February 27, 2019 11:42
Add custom field to order admin woocommerce
<?php
/**
* Display field value on the order edit page
*/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'wdt_delivery_date_admin_order_meta', 10, 1 );
function wdt_delivery_date_admin_order_meta($order){
global $wpdb;
$strSelect = "SELECT meta_key FROM {$wpdb->prefix}postmeta WHERE post_id = '" . $order->get_id() . "' AND meta_key LIKE '_wdt_slot_%'";
@vidishpurohit
vidishpurohit / gist:4973f69cc21ef34ca4271d26f38dacbf
Created May 10, 2018 06:11
add subtotal to edit order admin woocommerce
/*
* This code will add subtotal to edit order admin woocommerce.
* Author: WooExtend
* Date: 13-02-2018
*/
add_action( 'woocommerce_admin_order_totals_after_discount', 'vp_add_sub_total', 10, 1);
function vp_add_sub_total( $order_id ) {
$order = wc_get_order( $order_id );
?><tr>
<td class="label">Subtotal:</td>