php


Duplicate per-product shipping extension information - WooCommerce


on my wordpress site I have WooCommerce and the WooCommerce per product shipping extension (https://docs.woocommerce.com/document/per-product-shipping/). I currently have an issue, this is that whenever I duplicate a woocommerce product the per-product shipping information is not copied. I have tried to find a solution for this and have got the following code however I have not been able to get it work, can anyone see what is going wrong in the following
add_action( 'woocommerce_product_duplicate', 'wdm_duplicate_pps_entries',10,2);
function wdm_duplicate_pps_entries( $new_id, $post) {
global $wpdb;
$id = isset( $_REQUEST['post'] ) ? absint( $_REQUEST['post'] ) : '';
if(!empty($id)) {
$query = "Select * From " . $wpdb->prefix . "woocommerce_per_product_shipping_rule
Where product_id = '" . $id . "'";
$result = $wpdb->get_results($query);
$table_name = $wpdb->prefix . "woocommerce_per_product_shipping_rule";
foreach($result as $single_result) {
$data = array('product_id' => $new_id, 'rule_country' => $single_result->rule_country, 'rule_state' => $single_result->rule_state,'rule_postcode' => $single_result->rule_postcode,'rule_cost' => $single_result->rule_cost,'rule_item_cost' => $single_result->rule_item_cost,'rule_order' => $single_result->rule_order);
$wpdb->insert($table_name,$data);
}
}
}
This is an example of the additonal info I am trying to copy -

Related Links

How to set logout automatically in PHP after session ends
how to set featured image in non-wordpress
MongoDB find document in collection based on 2 IDs PHP
php mysql join 2 tables and get limited rows from each group
some definition is not working in *.po file
Selecting a unique cell from a dynamic generated table
How to get sum of few radio button values in a foreach loop
Function not working in PHP $_GET[]
CodeIgniter, Codeigniter/AJAX search with dropdown
Check form fields on php
How to get the last parameter requested by a certain url in PHP
PHP Error - Invalid request (An existing connection was forcibly closed by the remote host)
Ingram micro integration using PHP
how to control concurrent operation of multiple users
image extension validation error
Removing/ignoring html tags in csv file

Categories

HOME
xpath
functional-programming
schema.org
kendo-dropdown
foaf
mousemove
hid
filesize
initialization
typeerror
fogbugz
elk-stack
flurry
haxe
u-boot
native-base
anchor
azure-logic-apps
getopenfilename
erd
bootstrap-switch
dhcp
trace32
sonicwall
heap-dump
bnf
cpu-usage
sharedpreferences
amazon-sns
exchange-server-2010
restier
react-dnd
nurbs
tortoisemerge
strophe.js
background-color
oracleforms
ccavenue
envoy
private-key
appcode
gnu-classpath
cmis
xvfb
identify
windows-store
cloudera-sentry
supertest
nusoap
phppgadmin
sequence-diagram
glassfish-4.1
dblink
apache-modules
dymola
front-camera
email-injection
controllers
android-sdcard
ajaxmin
uibinder
distributed-cache
helm
juniper-network-connect
mousehover
ambiguity
embeddedwebserver
textscan
global-scope
smacss
inequality
loginview
category-theory
csslint
pageviews
jack
boolean-algebra
gpu-programming
jms-serializer
smips
virtual-channel
node.js-stream
office-app
email-verification
tridion-2011
xalan
story
playorm
workflow-manager-1.x
platform-independent
monocross
django-apps
drawimage
play2-mini
kext
webresponse
channelfactory
iphone-sdk-4.3
.net-services

Resources

Encrypt Message