$crowdfunding_enabled = get_post_meta( $post_id, '_alg_crowdfunding_enabled', true );
if( $crowdfunding_enabled ) {
if( get_post_meta( $product_id, '_' . 'alg_crowdfunding_goal_sum', true ) > 0 ) {
public function _update_order_status( $order, $timeline ) {
$prev_status = $order->get_meta( '_coinbase_status' );
$last_update = end( $timeline );
$status = $last_update['status'];
if ( $status !== $prev_status ) {
$order->update_meta_data( '_coinbase_status', $status );
if ( 'EXPIRED' === $status && 'pending' == $order->get_status() ) {
$order->update_status( 'cancelled', __( 'Coinbase payment expired.', 'coinbase' ) );
} elseif ( 'CANCELED' === $status ) {
$order->update_status( 'cancelled', __( 'Coinbase payment cancelled.', 'coinbase' ) );
} elseif ( 'UNRESOLVED' === $status ) {
if ($last_update['context'] === 'OVERPAID') {
$order->update_status( 'processing', __( 'Coinbase payment was successfully processed.', 'coinbase' ) );
$order->payment_complete();
} else {
// translators: Coinbase error status for "unresolved" payment. Includes error status.
$order->update_status( 'failed', sprintf( __( 'Coinbase payment unresolved, reason: %s.', 'coinbase' ), $last_update['context'] ) );
}
} elseif ( 'PENDING' === $status ) {
$order->update_status( 'blockchainpending', __( 'Coinbase payment detected, but awaiting blockchain confirmation.', 'coinbase' ) );
} elseif ( 'RESOLVED' === $status ) {
// We don't know the resolution, so don't change order status.
$order->add_order_note( __( 'Coinbase payment marked as resolved.', 'coinbase' ) );
} elseif ( 'waitingforthegoal' === $status ) {
$order->update_status( 'processing', __( 'Coinbase payment was successfully processed.', 'coinbase' ) );
$order->payment_complete();
}
}
elseif
public function _update_order_status( $order, $timeline ) {
$prev_status = $order->get_meta( '_coinbase_status' );
$last_update = end( $timeline );
$status = $last_update['status'];
if ( $status !== $prev_status ) {
$order->update_meta_data( '_coinbase_status', $status );
if ( 'EXPIRED' === $status && 'pending' == $order->get_status() ) {
$order->update_status( 'cancelled', __( 'Coinbase payment expired.', 'coinbase' ) );
} elseif ( 'CANCELED' === $status ) {
$order->update_status( 'cancelled', __( 'Coinbase payment cancelled.', 'coinbase' ) );
} elseif ( 'UNRESOLVED' === $status ) {
if ($last_update['context'] === 'OVERPAID') {
$order->update_status( 'processing', __( 'Coinbase payment was successfully processed.', 'coinbase' ) );
$order->payment_complete();
} else {
// translators: Coinbase error status for "unresolved" payment. Includes error status.
$order->update_status( 'failed', sprintf( __( 'Coinbase payment unresolved, reason: %s.', 'coinbase' ), $last_update['context'] ) );
}
} elseif ( 'PENDING' === $status ) {
$order->update_status( 'blockchainpending', __( 'Coinbase payment detected, but awaiting blockchain confirmation.', 'coinbase' ) );
} elseif ( 'RESOLVED' === $status ) {
// We don't know the resolution, so don't change order status.
$order->add_order_note( __( 'Coinbase payment marked as resolved.', 'coinbase' ) );
} elseif ( 'COMPLETED' === $status ) {
$order->update_status( 'processing', __( 'Coinbase payment was successfully processed.', 'coinbase' ) );
$order->payment_complete();
}
}
}
}