Add actions for attribute create/update/delete
As committed on master branch via: - https://github.com/woothemes/woocommerce/pull/3298
This commit is contained in:
parent
ed0bfbf62c
commit
0d554994e6
|
@ -100,32 +100,35 @@ function woocommerce_attributes() {
|
||||||
|
|
||||||
// Add new attribute
|
// Add new attribute
|
||||||
if ( 'add' === $action ) {
|
if ( 'add' === $action ) {
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . 'woocommerce_attribute_taxonomies',
|
$attribute = array(
|
||||||
array(
|
|
||||||
'attribute_label' => $attribute_label,
|
'attribute_label' => $attribute_label,
|
||||||
'attribute_name' => $attribute_name,
|
'attribute_name' => $attribute_name,
|
||||||
'attribute_type' => $attribute_type,
|
'attribute_type' => $attribute_type,
|
||||||
'attribute_orderby' => $attribute_orderby,
|
'attribute_orderby' => $attribute_orderby,
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$wpdb->insert( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute );
|
||||||
|
|
||||||
|
do_action( 'woocommerce_attribute_added', $wpdb->insert_id, $attribute );
|
||||||
|
|
||||||
$action_completed = true;
|
$action_completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit existing attribute
|
// Edit existing attribute
|
||||||
if ( 'edit' === $action ) {
|
if ( 'edit' === $action ) {
|
||||||
$wpdb->update(
|
|
||||||
$wpdb->prefix . 'woocommerce_attribute_taxonomies',
|
$attribute = array(
|
||||||
array(
|
|
||||||
'attribute_label' => $attribute_label,
|
'attribute_label' => $attribute_label,
|
||||||
'attribute_name' => $attribute_name,
|
'attribute_name' => $attribute_name,
|
||||||
'attribute_type' => $attribute_type,
|
'attribute_type' => $attribute_type,
|
||||||
'attribute_orderby' => $attribute_orderby,
|
'attribute_orderby' => $attribute_orderby,
|
||||||
),
|
|
||||||
array( 'attribute_id' => $attribute_id )
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$wpdb->update( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute, array( 'attribute_id' => $attribute_id ) );
|
||||||
|
|
||||||
|
do_action( 'woocommerce_attribute_updated', $attribute_id, $attribute, $old_attribute_name );
|
||||||
|
|
||||||
if ( $old_attribute_name != $attribute_name && ! empty( $old_attribute_name ) ) {
|
if ( $old_attribute_name != $attribute_name && ! empty( $old_attribute_name ) ) {
|
||||||
// Update taxonomies in the wp term taxonomy table
|
// Update taxonomies in the wp term taxonomy table
|
||||||
$wpdb->update(
|
$wpdb->update(
|
||||||
|
@ -183,6 +186,8 @@ function woocommerce_attributes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_action( 'woocommerce_attribute_deleted', $attribute_id, $attribute_name, $taxonomy );
|
||||||
|
|
||||||
$action_completed = true;
|
$action_completed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
= 2.0.12 - x =
|
= 2.0.12 - x =
|
||||||
|
* Tweak - Add actions for attribute create/update/delete
|
||||||
* Fix - Fixed bug in cross sells loading in product data write panel
|
* Fix - Fixed bug in cross sells loading in product data write panel
|
||||||
* Fix - Fixed posting shipping method when only one is available
|
* Fix - Fixed posting shipping method when only one is available
|
||||||
* Fix - Fixed query breaking when using some product widgets
|
* Fix - Fixed query breaking when using some product widgets
|
||||||
|
|
Loading…
Reference in New Issue