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:
Coen Jacobs 2013-06-17 16:15:24 +02:00
parent ed0bfbf62c
commit 0d554994e6
2 changed files with 24 additions and 18 deletions

View File

@ -100,32 +100,35 @@ function woocommerce_attributes() {
// Add new attribute
if ( 'add' === $action ) {
$wpdb->insert(
$wpdb->prefix . 'woocommerce_attribute_taxonomies',
array(
'attribute_label' => $attribute_label,
'attribute_name' => $attribute_name,
'attribute_type' => $attribute_type,
'attribute_orderby' => $attribute_orderby,
)
$attribute = array(
'attribute_label' => $attribute_label,
'attribute_name' => $attribute_name,
'attribute_type' => $attribute_type,
'attribute_orderby' => $attribute_orderby,
);
$wpdb->insert( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute );
do_action( 'woocommerce_attribute_added', $wpdb->insert_id, $attribute );
$action_completed = true;
}
// Edit existing attribute
if ( 'edit' === $action ) {
$wpdb->update(
$wpdb->prefix . 'woocommerce_attribute_taxonomies',
array(
'attribute_label' => $attribute_label,
'attribute_name' => $attribute_name,
'attribute_type' => $attribute_type,
'attribute_orderby' => $attribute_orderby,
),
array( 'attribute_id' => $attribute_id )
$attribute = array(
'attribute_label' => $attribute_label,
'attribute_name' => $attribute_name,
'attribute_type' => $attribute_type,
'attribute_orderby' => $attribute_orderby,
);
$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 ) ) {
// Update taxonomies in the wp term taxonomy table
$wpdb->update(
@ -183,6 +186,8 @@ function woocommerce_attributes() {
}
}
do_action( 'woocommerce_attribute_deleted', $attribute_id, $attribute_name, $taxonomy );
$action_completed = true;
}
}

View File

@ -166,6 +166,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 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 posting shipping method when only one is available
* Fix - Fixed query breaking when using some product widgets