Skip to content

Commit

Permalink
feat: add dokan promotional notice (#455)
Browse files Browse the repository at this point in the history
* feat: add dokan promotional notice

* feat: add dokan christmas notice
  • Loading branch information
saimonh3 authored and sabbir1991 committed Dec 11, 2018
1 parent 1dc2b25 commit 19c908d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 100 deletions.
107 changes: 12 additions & 95 deletions includes/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function __construct() {

add_action( 'admin_notices', array($this, 'update_notice' ) );

// add_action( 'admin_notices', array($this, 'promotional_offer' ) );
add_action( 'admin_notices', array( $this, 'promotional_offer' ) );

add_action( 'wp_before_admin_bar_render', array( $this, 'dokan_admin_toolbar' ) );
}
Expand All @@ -42,113 +42,30 @@ public function promotional_offer() {
}

// check if it has already been dismissed
$offer_key = 'dokan_package_offer';
$hide_notice = get_option( $offer_key . '_tracking_notice', 'no' );
$offer_key = 'dokan_christmas_notice';
$hide_notice = get_option( $offer_key, 'show' );
$offer_link = 'https://wedevs.com/dokan/?add-to-cart=15310&variation_id=15316&coupon_code=xmas30';

if ( 'hide' == $hide_notice ) {
if ( 'hide' == $hide_notice || dokan()->is_pro_exists() ) {
return;
}

$offer_msg = sprintf( __( '<h2>
Dokan is Getting More Affordable: Price Reduction & Changes in Packages
</h2>', 'dokan-lite' ) );
$offer_msg .= sprintf( __( '<p>Marketplaces are changing, so is Dokan Multivendor. We are reducing Dokan Pro entry package price and bringing entirely new pricing where you get addons pre-activated for free depending on your package.</p>', 'dokan-lite' ) );
?>
<div class="notice is-dismissible" id="dokan-promotional-offer-notice">
<img src="https://ps.w.org/dokan-lite/assets/icon-256x256.png?rev=1595714" alt="">
<?php echo $offer_msg; ?>
<span class="dashicons dashicons-megaphone"></span>
<a href="https://wedevs.com/in/dokan-new-package-blog-via-lite" class="button button-primary promo-btn" target="_blank"><?php _e( 'View Package', 'dokan-lite' ); ?></a>
<div class="notice notice-success is-dismissible" id="dokan-christmas-notice">
<?php printf( __( '<p>Dokan is more affordable this Christmas! <strong>Save 30%%</strong> while building your dream multivendor marketplace. [Limited time ⏳] <a target="_blank" href="%s">Grab The Deal</a></p>', 'dokan-lite' ), $offer_link ); ?>
</div>

<style>
#dokan-promotional-offer-notice {
background-color: #F35E33;
border-left: 0px;
padding-left: 83px;
}

#dokan-promotional-offer-notice a.promo-btn{
background: #fff;
border-color: #fafafa #fafafa #fafafa;
box-shadow: 0 1px 0 #fafafa;
color: #F35E33;
text-decoration: none;
text-shadow: none;
position: absolute;
top: 30px;
right: 26px;
height: 40px;
line-height: 40px;
width: 130px;
text-align: center;
}

#dokan-promotional-offer-notice h2{
font-size: 18px;
width: 85%;
color: rgba(250, 250, 250, 1);
margin-bottom: 8px;
font-weight: normal;
margin-top: 15px;
-webkit-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
-moz-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
-o-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
}

#dokan-promotional-offer-notice img{
position: absolute;
width: 80px;
top: 10px;
left: 0px;
}

#dokan-promotional-offer-notice h2 span {
position: relative;
top: -1px;
}

#dokan-promotional-offer-notice p{
width: 85%;
color: rgba(250, 250, 250, 0.77);
font-size: 14px;
margin-bottom: 10px;
-webkit-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
-moz-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
-o-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24);
}

#dokan-promotional-offer-notice p strong.highlight-text{
color: #fff;
}

#dokan-promotional-offer-notice p a {
color: #fafafa;
#dokan-christmas-notice p {
font-size: 15px;
}

#dokan-promotional-offer-notice .notice-dismiss:before {
color: #fff;
}

#dokan-promotional-offer-notice span.dashicons-megaphone {
position: absolute;
top: 16px;
right: 248px;
color: rgba(253, 253, 253, 0.29);
font-size: 96px;
transform: rotate(-21deg);
}

</style>

<script type='text/javascript'>
jQuery('body').on('click', '#dokan-promotional-offer-notice .notice-dismiss', function(e) {
jQuery('body').on('click', '#dokan-christmas-notice .notice-dismiss', function(e) {
e.preventDefault();

wp.ajax.post('dokan-dismiss-promotional-offer-notice', {
dokan_promotion_dismissed: true
wp.ajax.post('dokan-dismiss-christmas-offer-notice', {
dokan_christmas_dismissed: true
});
});
</script>
Expand Down
11 changes: 6 additions & 5 deletions includes/admin/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Dokan_Admin_Ajax {
*/
function __construct() {
add_action( 'wp_ajax_dokan_withdraw_form_action', array( $this, 'handle_withdraw_action' ) );
add_action( 'wp_ajax_dokan-dismiss-promotional-offer-notice', array( $this, 'dismiss_promotional_offer' ) );
add_action( 'wp_ajax_dokan-dismiss-christmas-offer-notice', array( $this, 'dismiss_christmas_offer' ) );
// add_action( 'wp_ajax_dokan-dismiss-promotional-offer-notice', array( $this, 'dismiss_promotional_offer' ) );
}

/**
Expand Down Expand Up @@ -115,10 +116,10 @@ function handle_withdraw_action() {
*
* @return void
*/
public function dismiss_promotional_offer() {
if ( ! empty( $_POST['dokan_promotion_dismissed'] ) ) {
$offer_key = 'dokan_package_offer';
update_option( $offer_key . '_tracking_notice', 'hide' );
public function dismiss_christmas_offer() {
if ( ! empty( $_POST['dokan_christmas_dismissed'] ) ) {
$offer_key = 'dokan_christmas_notice';
update_option( $offer_key, 'hide' );
}
}

Expand Down

0 comments on commit 19c908d

Please sign in to comment.