Skip to content

Commit

Permalink
[#37] Auction page (#87)
Browse files Browse the repository at this point in the history
* [#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
  • Loading branch information
nathan-schmidt-viget authored Dec 19, 2023
1 parent 7ccc537 commit 8ae1471
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions client-mu-plugins/goodbids/blocks/bid-now/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
29 changes: 29 additions & 0 deletions client-mu-plugins/goodbids/blocks/reward-product-gallery/block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Initialize the WooCommerce Gallery Script
*
* @since 1.0.0
*
* @return void
*/


add_action(
'wp_enqueue_scripts',
function () {
if ( is_singular( 'gb-auction' ) ) {
if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
wp_enqueue_script( 'zoom' );
}
if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
wp_enqueue_script( 'flexslider' );
}
if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
wp_enqueue_script( 'photoswipe-ui-default' );
wp_enqueue_style( 'photoswipe-default-skin' );
add_action( 'wp_footer', 'woocommerce_photoswipe' );
}
wp_enqueue_script( 'wc-single-product' );
}
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Block: Reward Product Gallery
*
* @global array $block
*
* @since 1.0.0
* @package GoodBids
*/

global $product;
$reward_id = goodbids()->auctions->get_reward_product_id( goodbids()->auctions->get_auction_id() );
$reward = wc_get_product( $reward_id );
if ( $reward ) {
$product = $reward;
}
?>


<section <?php block_attr( $block ); ?>>
<?php
if ( $product ) {
wc_get_template( 'single-product/product-image.php' );
} else {
printf(
'<p style="text-align: center;">%s</p>',
esc_html__( 'No Auction Product selected', 'goodbids' )
);
}
?>
</section>
15 changes: 15 additions & 0 deletions client-mu-plugins/goodbids/blocks/reward-product/block.json
Original file line number Diff line number Diff line change
@@ -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
}
}
43 changes: 43 additions & 0 deletions client-mu-plugins/goodbids/blocks/reward-product/render.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Block: Reward Product
*
* @global array $block
*
* @since 1.0.0
* @package GoodBids
*/

$goal = goodbids()->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 );
?>


<section <?php block_attr( $block ); ?>>
<?php
// Goal
if ( $goal ) {
printf(
'<p style="text-align: center;">%s</p>',
esc_html__( $goal, 'goodbids' )
);
}

// Estimated Value
if ( $estimated_value ) {
printf(
'<p style="text-align: center;">%s</p>',
esc_html__( $estimated_value, 'goodbids' )
);
}

// Expected High Bid
if ( $expected_high_bid ) {
printf(
'<p style="text-align: center;">%s</p>',
esc_html__( $expected_high_bid, 'goodbids' )
);
}
?>
</section>
12 changes: 8 additions & 4 deletions client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -150,7 +150,10 @@ private function get_template(): array {
'woocommerce_auction_default_template',
[
[
'acf/bid-now',
'core/pattern',
[
'slug' => 'goodbids/template-auction',
],
],
]
);
Expand All @@ -172,6 +175,7 @@ function () {
);
}


/**
* Returns the Auction post type slug.
*
Expand Down Expand Up @@ -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 );
Expand Down
13 changes: 13 additions & 0 deletions client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
);

Expand Down
39 changes: 39 additions & 0 deletions client-mu-plugins/goodbids/views/patterns/template-auction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Pattern: Auction Template
*
* Auto loaded as the default template for the gb-auction custom post type
*
* @since 1.0.0
* @package GoodBids
*/

?>

<!-- wp:group {"tagName":"main","align":"wide"} -->
<main class="wp-block-group alignwide">
<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:post-featured-image {"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|40"}}}} /-->

<!-- wp:acf/reward-product-gallery {"name":"acf/reward-product-gallery","mode":"preview"} /-->
</div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:post-title /-->

<!-- wp:post-excerpt /-->

<!-- wp:acf/reward-product {"name":"acf/reward-product","mode":"preview"} /-->

<!-- wp:acf/bid-now {"name":"acf/bid-now","data":{},"mode":"preview"} /-->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</main>
<!-- /wp:group -->
3 changes: 3 additions & 0 deletions themes/goodbids-nonprofit/templates/single-gb-auction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:template-part {"slug":"header","area":"header","tagName":"header"} /-->
<!-- wp:post-content {"lock":{"move":false,"remove":false},"align":"full"} /-->
<!-- wp:template-part {"slug":"footer","area":"footer","tagName":"footer"} /-->

0 comments on commit 8ae1471

Please sign in to comment.