From 8ae1471c8fd80ec2bd1de08a7d03334aba4f5eb5 Mon Sep 17 00:00:00 2001 From: Nathan Schmidt <91974372+nathan-schmidt-viget@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:58:44 -0700 Subject: [PATCH] [#37] Auction page (#87) * [#37] setting up new block and pattern * [#37] setting up test templates * [#37] place holder stuff * [#37] refactor and pulling in scripts * [#37] pulling the auction info * [#37] updating pattern adding bid-now block * [#37] adding reward product info * [#37] adding excerpt to action post * [#37] refactor moving pattern to mu plugin * [#37] Removing text if not custom values in Auction * [#37] refactor PR --- .../goodbids/blocks/authentication/block.json | 1 + .../goodbids/blocks/bid-now/block.json | 1 + .../blocks/reward-product-gallery/block.json | 15 +++++++ .../blocks/reward-product-gallery/block.php | 29 +++++++++++++ .../blocks/reward-product-gallery/render.php | 31 +++++++++++++ .../goodbids/blocks/reward-product/block.json | 15 +++++++ .../goodbids/blocks/reward-product/render.php | 43 +++++++++++++++++++ .../src/classes/Auctions/Auctions.php | 12 ++++-- .../src/classes/Frontend/Patterns.php | 13 ++++++ .../views/patterns/template-auction.php | 39 +++++++++++++++++ .../templates/single-gb-auction.html | 3 ++ 11 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 client-mu-plugins/goodbids/blocks/reward-product-gallery/block.json create mode 100644 client-mu-plugins/goodbids/blocks/reward-product-gallery/block.php create mode 100644 client-mu-plugins/goodbids/blocks/reward-product-gallery/render.php create mode 100644 client-mu-plugins/goodbids/blocks/reward-product/block.json create mode 100644 client-mu-plugins/goodbids/blocks/reward-product/render.php create mode 100644 client-mu-plugins/goodbids/views/patterns/template-auction.php create mode 100644 themes/goodbids-nonprofit/templates/single-gb-auction.html diff --git a/client-mu-plugins/goodbids/blocks/authentication/block.json b/client-mu-plugins/goodbids/blocks/authentication/block.json index 92f634df5..86eb7f047 100644 --- a/client-mu-plugins/goodbids/blocks/authentication/block.json +++ b/client-mu-plugins/goodbids/blocks/authentication/block.json @@ -4,6 +4,7 @@ "description": "Displays a user login and registration form for GoodBids.", "icon": "feedback", "category": "goodbids", + "textdomain": "goodbids", "keywords": ["custom", "sign", "up", "register", "registration", "form", "users", "authentication"], "acf": { "mode": "preview" diff --git a/client-mu-plugins/goodbids/blocks/bid-now/block.json b/client-mu-plugins/goodbids/blocks/bid-now/block.json index 9d44c7053..737758dbe 100644 --- a/client-mu-plugins/goodbids/blocks/bid-now/block.json +++ b/client-mu-plugins/goodbids/blocks/bid-now/block.json @@ -4,6 +4,7 @@ "description": "Displays a bid now button for the current Auction.", "icon": "money-alt", "category": "goodbids", + "textdomain": "goodbids", "keywords": ["bid", "purchase", "donate", "button", "submit", "cart"], "acf": { "mode": "preview" diff --git a/client-mu-plugins/goodbids/blocks/reward-product-gallery/block.json b/client-mu-plugins/goodbids/blocks/reward-product-gallery/block.json new file mode 100644 index 000000000..66b04e7fa --- /dev/null +++ b/client-mu-plugins/goodbids/blocks/reward-product-gallery/block.json @@ -0,0 +1,15 @@ +{ + "name": "reward-product-gallery", + "title": "Reward Product Gallery", + "description": "Displays the reward product gallery images", + "icon": "format-gallery", + "category": "goodbids", + "textdomain": "goodbids", + "keywords": ["custom", "gallery", "product", "reward", "auction"], + "acf": { + "mode": "preview" + }, + "supports": { + "jsx": false + } +} diff --git a/client-mu-plugins/goodbids/blocks/reward-product-gallery/block.php b/client-mu-plugins/goodbids/blocks/reward-product-gallery/block.php new file mode 100644 index 000000000..c99c18131 --- /dev/null +++ b/client-mu-plugins/goodbids/blocks/reward-product-gallery/block.php @@ -0,0 +1,29 @@ +auctions->get_reward_product_id( goodbids()->auctions->get_auction_id() ); +$reward = wc_get_product( $reward_id ); +if ( $reward ) { + $product = $reward; +} +?> + + +
> + %s

', + esc_html__( 'No Auction Product selected', 'goodbids' ) + ); + } + ?> +
diff --git a/client-mu-plugins/goodbids/blocks/reward-product/block.json b/client-mu-plugins/goodbids/blocks/reward-product/block.json new file mode 100644 index 000000000..f668b4b27 --- /dev/null +++ b/client-mu-plugins/goodbids/blocks/reward-product/block.json @@ -0,0 +1,15 @@ +{ + "name": "reward-product", + "title": "Reward Product", + "description": "Displays the reward product information", + "icon": "awards", + "category": "goodbids", + "textdomain": "goodbids", + "keywords": ["custom", "product", "reward", "auction"], + "acf": { + "mode": "preview" + }, + "supports": { + "jsx": false + } +} diff --git a/client-mu-plugins/goodbids/blocks/reward-product/render.php b/client-mu-plugins/goodbids/blocks/reward-product/render.php new file mode 100644 index 000000000..105fa9d87 --- /dev/null +++ b/client-mu-plugins/goodbids/blocks/reward-product/render.php @@ -0,0 +1,43 @@ +auctions->get_goal( goodbids()->auctions->get_auction_id() ); +$estimated_value = goodbids()->auctions->get_estimated_value( $auction_id ); +$expected_high_bid = goodbids()->auctions->get_expected_high_bid( $auction_id ); +?> + + +
> + %s

', + esc_html__( $goal, 'goodbids' ) + ); + } + + // Estimated Value + if ( $estimated_value ) { + printf( + '

%s

', + esc_html__( $estimated_value, 'goodbids' ) + ); + } + + // Expected High Bid + if ( $expected_high_bid ) { + printf( + '

%s

', + esc_html__( $expected_high_bid, 'goodbids' ) + ); + } + ?> +
diff --git a/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php b/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php index ddf2a4037..af4687cf0 100644 --- a/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php +++ b/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php @@ -113,7 +113,7 @@ function () { 'label' => __( 'Auction', 'goodbids' ), 'description' => __( 'GoodBids Auction Custom Post Type', 'goodbids' ), 'labels' => $labels, - 'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions' ), + 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, @@ -150,7 +150,10 @@ private function get_template(): array { 'woocommerce_auction_default_template', [ [ - 'acf/bid-now', + 'core/pattern', + [ + 'slug' => 'goodbids/template-auction', + ], ], ] ); @@ -172,6 +175,7 @@ function () { ); } + /** * Returns the Auction post type slug. * @@ -279,8 +283,8 @@ public function set_bid_product_id( int $auction_id, int $bid_product_id ): void * @return mixed */ public function get_setting( string $meta_key, int $auction_id = null ): mixed { - if ( ! $auction_id ) { - $auction_id = get_the_ID(); + if ( null === $auction_id ) { + $auction_id = $this->get_auction_id(); } return get_field( $meta_key, $auction_id ); diff --git a/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php b/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php index 2a3a3b1b8..aa4e749ff 100644 --- a/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php +++ b/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php @@ -64,10 +64,23 @@ function (): void { 'inserter' => true, ]; + $template_auction = [ + 'name' => 'template-auction', + 'path' => GOODBIDS_PLUGIN_PATH . 'views/patterns/template-auction.php', + 'title' => __( 'Auction', 'goodbids' ), + 'description' => _x( 'Template for GoodBids Auction Page', 'Block pattern description', 'goodbids' ), + 'categories' => [ 'page', 'goodbids' ], + 'keywords' => [ 'non-profit', 'auction' ], + 'postTypes' => [ 'gb-auction', 'wp_template' ], + 'source' => 'theme', + 'inserter' => false, + ]; + $this->patterns = apply_filters( 'goodbids_block_patterns', [ $auction_archive, + $template_auction, ] ); diff --git a/client-mu-plugins/goodbids/views/patterns/template-auction.php b/client-mu-plugins/goodbids/views/patterns/template-auction.php new file mode 100644 index 000000000..9cf1c5305 --- /dev/null +++ b/client-mu-plugins/goodbids/views/patterns/template-auction.php @@ -0,0 +1,39 @@ + + + +
+ +
+ +
+ + + +
+ + + +
+ + + + + + + +
+ +
+ +
+ diff --git a/themes/goodbids-nonprofit/templates/single-gb-auction.html b/themes/goodbids-nonprofit/templates/single-gb-auction.html new file mode 100644 index 000000000..6b7823a1b --- /dev/null +++ b/themes/goodbids-nonprofit/templates/single-gb-auction.html @@ -0,0 +1,3 @@ + + +