Skip to content

Commit

Permalink
[#739] Reward Product Email Triggers, Emails, and Start/End Auction E…
Browse files Browse the repository at this point in the history
…vents (#742)

* [#717] Bid/Reward URLs Refactor

* [#717] Perform Final Bid Product Check

* [#717] Resolve Duplicate Bid Race Conditions

* [N/A] Fix Reward Claimed Email bug

* [#717] Remove unnecessary parameter counts

* [#717] Remove WC Notice by ID

* [N/A] Fixes a PHP Error

* [#739] WIP

- Fixed Local Auction Wizard Creation
- Added debug logging to determine order of events

* [#739] Failsafe to change Reward Product Price

* [#739] Cron Adjustments

* [#739] Earlier initialization of Emails

* [#739] Remove debugging notes

* [#739] Removed unused class imports

* [#739] Use Free Bid Param

* [#739] useFreeBidParam

* [#739] Fix PHP Error
  • Loading branch information
bd-viget authored Mar 14, 2024
1 parent cbcb7d0 commit 86de9e8
Show file tree
Hide file tree
Showing 29 changed files with 775 additions and 578 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ export function FreeBidButton() {
userFreeBids,
auctionStatus,
bidUrl,
useFreeBidParam,
freeBidsAllowed,
isLastBidder,
userId,
} = useBiddingState();

const disabled = isLastBidder || userFreeBids < 1;

const freeBidUrl = `${bidUrl}?use-free-bid=1`;
const freeBidUrl = `${bidUrl}?${useFreeBidParam}=1`;

const classes = clsx('btn-fill-secondary text-center', {
'pointer-events-none cursor-not-allowed !text-contrast-4': disabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const useBiddingStore = create<BiddingState & BiddingActions>((set) => ({
currentBid: 0,
lastBid: 0,
lastBidder: undefined,
useFreeBidParam: 'use-free-bid',
freeBidsAvailable: 0,
freeBidsAllowed: false,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type BidsType = {
currentBid: number;
lastBid: number;
lastBidder?: number | null;
useFreeBidParam: 'use-free-bid';
freeBidsAvailable: number;
freeBidsAllowed: boolean;
};
Expand Down
43 changes: 42 additions & 1 deletion client-mu-plugins/goodbids/src/classes/Auctions/Auction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use GoodBids\Nonprofits\Invoices;
use GoodBids\Utilities\Log;
use WC_Order;
use WC_Product;
use WP_Post;
use WP_User;

/**
Expand Down Expand Up @@ -97,7 +99,15 @@ class Auction {
* @since 1.0.0
* @var ?int
*/
private ?int $auction_id;
private ?int $auction_id = null;

/**
* The Auction ID.
*
* @since 1.0.0
* @var ?WP_Post
*/
private ?WP_Post $post;

/**
* Use metadata or get_field()
Expand All @@ -119,7 +129,12 @@ public function __construct( ?int $auction_id = null ) {
$auction_id = goodbids()->auctions->get_auction_id();
}

if ( ! $auction_id ) {
return;
}

$this->auction_id = $auction_id;
$this->post = get_post( $this->auction_id );
}

/**
Expand All @@ -132,6 +147,17 @@ public function get_id(): ?int {
return $this->auction_id;
}

/**
* Check if Auction is Valid
*
* @since 1.0.0
*
* @return bool
*/
public function is_valid(): bool {
return is_null( $this->post );
}

/**
* Get the URL for the Auction
*
Expand Down Expand Up @@ -284,6 +310,17 @@ public function get_reward_id(): int {
return goodbids()->rewards->get_product_id( $this->get_id() );
}

/**
* Get Reward Product
*
* @since 1.0.0
*
* @return ?WC_Product
*/
public function get_reward(): ?WC_Product {
return goodbids()->rewards->get_product( $this->get_id() );
}

/**
* Get Claim Reward URL
*
Expand Down Expand Up @@ -1069,6 +1106,10 @@ public function trigger_start(): bool {
update_post_meta( $this->get_id(), self::AUCTION_STARTED_META_KEY, 1 );

/**
* Called when an Auction has started.
*
* @since 1.0.0
*
* @param int $auction_id
*/
do_action( 'goodbids_auction_start', $this->get_id() );
Expand Down
Loading

0 comments on commit 86de9e8

Please sign in to comment.