-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
338 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
client-mu-plugins/goodbids/src/classes/Plugins/WooCommerce/Emails/AuctionIsEndingSoon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
/** | ||
* Auction is Ending Soon: Email the Watchers when an Auction is 1 hour from closing. | ||
* | ||
* @since 1.0.0 | ||
* @package GoodBids | ||
*/ | ||
|
||
namespace GoodBids\Plugins\WooCommerce\Emails; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Auction Ending Soon Email | ||
* | ||
* @since 1.0.0 | ||
* @extends Email | ||
*/ | ||
class AuctionIsEndingSoon extends Email { | ||
|
||
/** | ||
* Set the unique Email ID | ||
* | ||
* @since 1.0.0 | ||
* @var string | ||
*/ | ||
public $id = 'goodbids_auction_ending_soon'; | ||
|
||
/** | ||
* Set email defaults | ||
* | ||
* @since 1.0.0 | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
|
||
$this->title = __( 'Auction is Ending Soon', 'goodbids' ); | ||
$this->description = __( 'Notification email sent to all Bidders & Watchers when an Auction is near closing.', 'goodbids' ); | ||
$this->template_html = 'emails/auction-is-ending-soon.php'; | ||
$this->template_plain = 'emails/plain/auction-is-ending-soon.php'; | ||
$this->bidder_email = true; | ||
$this->watcher_email = true; | ||
|
||
$this->cron_check_for_auctions_ending_soon(); | ||
} | ||
|
||
/** | ||
* Trigger this email when an Auction is within 4 hours of closing | ||
* | ||
* @since 1.0.0 | ||
* | ||
* @return void | ||
*/ | ||
private function cron_check_for_auctions_ending_soon(): void { | ||
add_action( | ||
Auctions::CRON_AUCTION_ENDING_SOON_CHECK_HOOK, | ||
function (): void { | ||
$auctions = goodbids()->auctions->get_auctions_ending_soon_emails(); | ||
if (! $auctions){ | ||
return; | ||
} | ||
foreach ($auctions as $auction_id){ | ||
$auction = goodbids()->auctions->get( $auction_id ); | ||
$this->send_to_bidders( $auction ); | ||
$this->send_to_watchers( $auction ); | ||
} | ||
} | ||
) | ||
} | ||
|
||
/** | ||
* Get email subject. | ||
* | ||
* @since 1.0.0 | ||
* @return string | ||
*/ | ||
public function get_default_subject(): string { | ||
return sprintf( | ||
// translators: %1$s: Site Name, %2$s: Auction Title | ||
__( '[%1$s] %2$s auction is ending soon', 'goodbids' ), | ||
'{site_title}', | ||
'{auction.title}' | ||
); | ||
} | ||
|
||
/** | ||
* Get email heading. | ||
* | ||
* @since 1.0.0 | ||
* @return string | ||
*/ | ||
public function get_default_heading(): string { | ||
return __( 'Don\'t miss out!', 'goodbids' ); | ||
} | ||
|
||
/** | ||
* Get button text | ||
* | ||
* @since 1.0.0 | ||
* @return string | ||
*/ | ||
public function get_default_button_text(): string { | ||
return __( 'Bid Now', 'goodbids' ); | ||
} | ||
|
||
/** | ||
* Set Button URL | ||
* | ||
* @since 1.0.0 | ||
* | ||
* @return string | ||
*/ | ||
public function get_button_url(): string { | ||
return '{auction.url}'; | ||
} | ||
|
||
|
||
} |
80 changes: 80 additions & 0 deletions
80
client-mu-plugins/goodbids/views/woocommerce/emails/auction-is-ending-soon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* Auction Ending Soon email | ||
* | ||
* @since 1.0.0 | ||
* @version 1.0.0 | ||
* @package GoodBids | ||
* | ||
* @var string $email_heading | ||
* | ||
* @var AuctionIsEndingSoon $instance | ||
*/ | ||
|
||
use GoodBids\Plugins\WooCommerce\Emails\AuctionIsEndingSoon; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/* | ||
* @hooked WC_Emails::email_header() Output the email header | ||
*/ | ||
do_action( 'woocommerce_email_header', $email_heading ); | ||
?> | ||
|
||
<p> | ||
<?php | ||
printf( | ||
'%s <a href="%s">%s</a> %s', | ||
|
||
// Before | ||
sprintf( | ||
/* translators: %1$s: Auction Title */ | ||
esc_html__( 'The %1$s auction is ending soon.', 'goodbids' ), | ||
'{auction.title}' | ||
), | ||
|
||
// URL | ||
'{auction.url}', | ||
|
||
// Link Text | ||
esc_html__( 'Visit the auction', 'goodbids' ), | ||
|
||
// After. | ||
sprintf( | ||
/* translators: %1$s: Site Title, Reward Product Title */ | ||
esc_html__( 'to support %1$s\'s mission and place a bid for your chance to win the %2$s!', 'goodbids' ), | ||
'{site_title}', | ||
'{reward.title}' | ||
) | ||
); | ||
?> | ||
</p> | ||
|
||
<p> | ||
<?php | ||
printf( | ||
'%s %s %s <strong>%s</strong> %s', | ||
/* translators: %1$s: Auction total raised, %2$s: current high bid */ | ||
esc_html__( 'We\ve already raised', 'goodbids' ), | ||
'{auction.total_raised}', | ||
esc_html__( 'and the', 'goodbids' ), | ||
esc_html__( 'current high bid is ', 'goodbids' ), | ||
'{auction.high_bid}' | ||
); | ||
?> | ||
</p> | ||
|
||
<p> | ||
<?php | ||
printf( | ||
/* translators: %1$s: Site Name */ | ||
esc_html__( 'Every GOODBID on this auction is a donation to %1$s.', 'goodbids' ), | ||
'{site_title}' | ||
); | ||
?> | ||
</p> | ||
|
||
<?php | ||
|
||
/* * @hooked WC_Emails::email_footer() Output the email footer */ | ||
do_action( 'woocommerce_email_footer' ); |
39 changes: 39 additions & 0 deletions
39
client-mu-plugins/goodbids/views/woocommerce/emails/plain/auction-is-ending-soon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Auction Ending Soon email (plain text) | ||
* | ||
* @since 1.0.0 | ||
* @version 1.0.0 | ||
* @package GoodBids | ||
* | ||
* @var AuctionIsEndingSoon $instance | ||
*/ | ||
|
||
use GoodBids\Plugins\WooCommerce\Emails\AuctionIsEndingSoon; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** @var WC_Order $bid_order */ | ||
$bid_order = $instance->object; | ||
|
||
$instance->plain_text_header(); | ||
|
||
printf( | ||
/* translators: %1$s: Auction Title, %2$s: total raised, %3$s: Site title, %4$s: High bid, %5$s: auction url */ | ||
esc_html__( 'The auction you\'re watching, %1$s, is ending soon. It\'s already raised %2$s for %3$s, with a current high bid of %4$s. Let\'s see how much more can we raise: %5$s', 'goodbids' ), | ||
'{auction.title}', | ||
'{auction.total_raised}', | ||
'{site_title}', | ||
'{auction.high_bid}', | ||
'{auction.url}' | ||
); | ||
|
||
echo "\n\n----------------------------------------\n\n"; | ||
|
||
esc_html_e( 'Auction', 'goodbids' ) . ': ' . '{auction.title}' . "\n"; | ||
esc_html_e( 'Total Raised', 'goodbids' ) . ': ' . '{auction.total_raised}' . "\n"; | ||
esc_html_e( 'High Bid', 'goodbids' ) . ': ' . '{auction.high_bid}' . "\n"; | ||
|
||
echo "\n\n----------------------------------------\n\n"; | ||
|
||
$instance->plain_text_footer(); |