|
@@ 758-763 (lines=6) @@
|
| 755 |
|
function wpinv_update_item( $args = array(), $wp_error = false ) { |
| 756 |
|
$item = !empty( $args['ID'] ) ? new WPInv_Item( $args['ID'] ) : NULL; |
| 757 |
|
|
| 758 |
|
if ( empty( $item ) || !( !empty( $item->post_type ) && $item->post_type == 'wpi_item' ) ) { |
| 759 |
|
if ( $wp_error ) { |
| 760 |
|
return new WP_Error( 'wpinv_invalid_item', __( 'Invalid item.', 'invoicing' ) ); |
| 761 |
|
} |
| 762 |
|
return 0; |
| 763 |
|
} |
| 764 |
|
|
| 765 |
|
if ( !empty( $args['custom_id'] ) ) { |
| 766 |
|
$item_exists = wpinv_get_item_by( 'custom_id', $args['custom_id'], ( !empty( $args['type'] ) ? $args['type'] : $item->type ) ); |
|
@@ 768-773 (lines=6) @@
|
| 765 |
|
if ( !empty( $args['custom_id'] ) ) { |
| 766 |
|
$item_exists = wpinv_get_item_by( 'custom_id', $args['custom_id'], ( !empty( $args['type'] ) ? $args['type'] : $item->type ) ); |
| 767 |
|
|
| 768 |
|
if ( !empty( $item_exists ) && $item_exists->ID != $args['ID'] ) { |
| 769 |
|
if ( $wp_error ) { |
| 770 |
|
return new WP_Error( 'wpinv_invalid_custom_id', __( 'Item with custom id already exists.', 'invoicing' ) ); |
| 771 |
|
} |
| 772 |
|
return 0; |
| 773 |
|
} |
| 774 |
|
} |
| 775 |
|
|
| 776 |
|
$meta_fields = array( 'type', 'custom_id', 'custom_singular_name', 'custom_name', 'price', 'editable', 'vat_rule', 'vat_class', 'is_recurring', 'recurring_period', 'recurring_interval', 'recurring_limit', 'free_trial', 'trial_period', 'trial_interval' ); |