Code giảm giá (gifodi – monvinha)

Eric (kedochanh)
0
15/07/25
15/07/2025

Code tiết kiệm gifodi

 <?php if( $product->is_on_sale()){
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_price();
$sale_amout = $regular_price - $sale_price;
$saving_percentage = round(((floatval($regular_price) - floatval($sale_price)) / floatval($regular_price)) * 100);echo '<div class="savi"><span class="txt">Giảm '.wc_price($sale_amout).'';echo '<span class="savi-per">'. ($saving_percentage).'%'.'</span></span></div>'
;};?>
.savi{background:#FFFF00;/* linear-gradient( -90deg,#ec1f1f 0,#ff9c00 100%)*/;
    border-radius: 3px;}


.savi span.amount{color:#222;
    text-shadow: unset;}

.savi span.txt { display: flex;
    justify-content: end;
    font-size: 9px;
    align-items: baseline;
    margin-right:5px;}

.savi-per{
  position:absolute;top:25px;left: -5px;
    color: #f8e81c;font-size:12px;background: #222;
    padding: 0 5px;
    z-index: 4;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 13px;
    box-shadow: 0px 0px 4px 0px #f8e81c;}

.savi-per:after {
    content: '';
    position: absolute;
    border-style: solid;
    border-width: 0 5px 5px 0;
    border-color: transparent #222 transparent transparent;
    bottom: -5px;
    left: 0px;
    filter: brightness(2.8);}
.savi-txt {font-size: 14px;margin: -5px 0 5px;text-align:center;color:red;}

Code tiết kiệm món vị nhà

  <?php if( $product->is_on_sale()){
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_price();
$sale_amout = $regular_price - $sale_price;
$saving_percentage = round(((floatval($regular_price) - floatval($sale_price)) / floatval($regular_price)) * 100);echo '<span class="savi">Giảm '.'<span style="color:white;"'.wc_price($sale_amout) .'</span>';echo '<span class="savi-per">'. ($saving_percentage).'%'.'</span>'
;};?>
.savi{position: absolute;top:-4px;margin: 10px 0;padding:3px 5px 0 10px;
    background-image: linear-gradient( -90deg,#ec1f1f 0,#ff9c00 100%);
    border-radius: 4px;color: #fff;
}


.savi-per{
    position:absolute;
    top: 5px;
    left: -5px;
    color: #EEEE22;
    background: #222;
    padding: 4px 6px;
    z-index: 4;
    font-size: 14px;
    border-top-left-radius: 5px;
    border-top-right-radius: 13px;
    border-bottom-right-radius: 13px;
    box-shadow: 0px 0px 5px 1px #fff;
}

.savi-per:after {
  content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 5px 5px 0;
    border-color: transparent #222 transparent transparent;
    bottom: -5px;
    left: 0px;
    filter: brightness(1.8);
}

Tags :