Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update post meta 'status' as well as post_status #8909

Merged
merged 3 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion includes/api/class-edd-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,11 @@ public function output( $status_code = 200 ) {

do_action( 'edd_api_output_after', $this->data, $this, $format );

die();
if ( defined( 'EDD_DOING_TESTS' ) && EDD_DOING_TESTS ) {
edd_die();
} else {
die();
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions includes/class-edd-discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ public function update_status( $new_status = 'active' ) {
do_action( 'edd_post_update_discount_status', $this->ID, $new_status, $this->post_status );

if ( $id == $this->ID ) {
$this->update_meta( 'status', $new_status );
return true;
}

Expand Down
8 changes: 7 additions & 1 deletion tests/tests-discounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ public function test_updating_discount_code() {
$this->assertInternalType( 'int', $updated_post_id );
}

public function test_discount_status_update() {
public function test_discount_status_update_inactive() {
$this->assertTrue( edd_update_discount_status( $this->_post_id, 'inactive' ) );
$discount = edd_get_discount( $this->_post_id );
$this->assertEquals( 'inactive', $discount->status );

$this->assertTrue( edd_update_discount_status( $this->_post_id, 'active' ) );
$discount = edd_get_discount( $this->_post_id );
$this->assertEquals( 'active', $discount->status );
}

public function test_discount_status_update_fail() {
Expand Down