Skip to content

Commit

Permalink
Merge pull request #284 from athemes/dw-sprint-22
Browse files Browse the repository at this point in the history
Bulk discounts dynamic quantity
  • Loading branch information
DevWael authored Sep 5, 2024
2 parents 5059109 + 47aa36e commit 952950f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
50 changes: 49 additions & 1 deletion assets/sass/modules/volume-discounts/volume-discounts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
}

.offer-form {
margin-top: 10px;

.variation-form {
.variation-dropdown {
margin-bottom: 5px;
Expand Down Expand Up @@ -54,7 +56,7 @@
background-color: #fff;

.botiga-quantity-plus,
.botiga-quantity-minus{
.botiga-quantity-minus {
font-size: 14px;
color: #757575;
}
Expand Down Expand Up @@ -88,6 +90,52 @@
}
}
}

.user-message {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
border-radius: 5px;
visibility: hidden;
opacity: 0;
transition: 300ms;
background-color: rgba(0, 0, 0, 0.3);

&.show {
visibility: visible;
opacity: 1;
}

.message-text {
position: absolute;
top: 50%;
left: 40px;
right: 40px;
text-align: center;
font-weight: bold;
line-height: 50px;
border-radius: 5px;
user-select: none;
transform: translateY(-50%);
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
}

&.success {
.message-text {
background-color: #55c649;
color: #fff;
}
}

&.error {
.message-text {
background-color: #d83b3b;
color: #fff;
}
}
}
}

.merchant-volume-discounts-item ul {
Expand Down
25 changes: 15 additions & 10 deletions templates/modules/volume-discounts/single-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$product_id = get_the_ID();
$product = wc_get_product( $product_id );
$product = $args['product'];
$product_id = $product->get_id();
?>
<div class="merchant-volume-discounts">
<?php
Expand Down Expand Up @@ -207,21 +207,26 @@
<?php
endif; ?>
<div class="form-footer">
<div class="offer-quantity-input">
<?php
woocommerce_quantity_input( array(
'input_name' => 'offer-quantity',
'input_value' => $discount_qty,
) ) ?>
</div>
<?php
if ( $is_variable ) { ?>
<div class="offer-quantity-input">
<?php
woocommerce_quantity_input( array(
'input_name' => 'offer-quantity',
'input_value' => Merchant_Pro_Volume_Discounts::offer_dynamic_remaining_quantity( $discount_tier, $product ),
) ) ?>
</div>
<?php
} ?>
<div class="offer-submit">
<button type="submit">
<button type="submit" class="single_add_to_cart_button button alt">
<span class="offer-submit-text"><?php
esc_html_e( 'Add to cart', 'merchant' ); ?></span>
</button>
</div>
</div>
</div>
<div class="user-message"><span class="message-text"></span></div>
</div>
<?php
}
Expand Down

0 comments on commit 952950f

Please sign in to comment.