diff --git a/client-mu-plugins/goodbids/README.md b/client-mu-plugins/goodbids/README.md index c32597e92..78f547192 100644 --- a/client-mu-plugins/goodbids/README.md +++ b/client-mu-plugins/goodbids/README.md @@ -35,7 +35,10 @@ Renders an admin field based on the given field array. The `$prefix` and `$data` ### Auction Functions `goodbids()->auctions->get_post_type()` -Returns the auction post type slug. +Returns the Auction post type slug. + +`goodbids()->auctions->get_auction_id()` +Returns the current Auction ID (if valid). `goodbids()->auctions->get_setting( string $setting, int $auction_id )` Returns a setting value for an auction. If `$auction_id` is not provided, the current post ID will be used. diff --git a/client-mu-plugins/goodbids/acf-json/group_6570c1fa76181.json b/client-mu-plugins/goodbids/acf-json/group_6570c1fa76181.json index 805ec0b56..a0184fce7 100644 --- a/client-mu-plugins/goodbids/acf-json/group_6570c1fa76181.json +++ b/client-mu-plugins/goodbids/acf-json/group_6570c1fa76181.json @@ -43,7 +43,7 @@ "taxonomy": [ "product_cat:rewards" ], - "return_format": "object", + "return_format": "id", "multiple": 0, "allow_null": 0, "bidirectional": 0, @@ -179,6 +179,6 @@ "active": true, "description": "", "show_in_rest": 0, - "modified": 1702493167, + "modified": 1702659886, "private": true } diff --git a/client-mu-plugins/goodbids/blocks/bid-now/block.json b/client-mu-plugins/goodbids/blocks/bid-now/block.json new file mode 100644 index 000000000..9d44c7053 --- /dev/null +++ b/client-mu-plugins/goodbids/blocks/bid-now/block.json @@ -0,0 +1,14 @@ +{ + "name": "bid-now", + "title": "Bid Now Button", + "description": "Displays a bid now button for the current Auction.", + "icon": "money-alt", + "category": "goodbids", + "keywords": ["bid", "purchase", "donate", "button", "submit", "cart"], + "acf": { + "mode": "preview" + }, + "supports": { + "jsx": false + } +} diff --git a/client-mu-plugins/goodbids/blocks/bid-now/render.php b/client-mu-plugins/goodbids/blocks/bid-now/render.php new file mode 100644 index 000000000..8b8b57292 --- /dev/null +++ b/client-mu-plugins/goodbids/blocks/bid-now/render.php @@ -0,0 +1,28 @@ +auctions->get_post_type() !== get_post_type() ) : + // Bail early if we're not inside an Auction post type. + return; +endif; + +$auction_id = goodbids()->auctions->get_auction_id(); +$bid_product_id = goodbids()->auctions->get_bid_product_id( $auction_id ); + +$classes = 'wp-block-buttons is-vertical is-content-justification-center is-layout-flex wp-block-buttons-is-layout-flex'; +$button_url = $bid_product_id && ! is_admin() ? add_query_arg( 'add-to-cart', $bid_product_id, wc_get_checkout_url() ) : '#'; +?> +