Merge pull request #3298 from maxrice/master

Add actions for attribute create/update/delete
This commit is contained in:
Mike Jolley 2013-06-10 08:47:40 -07:00
commit 6da599156e
1 changed files with 23 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;
}
}
@ -422,4 +427,4 @@ function woocommerce_add_attribute() {
</script>
</div>
<?php
}
}