Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Function for display lot quantity
- *
- */
- function show_lot_discount(){
- global $post;
- $product = wc_get_product($post->ID);
- $product_id = $product->get_id();
- $is_lot_discount = get_post_meta( $product_id, '_is_lot_discount', true );
- if($is_lot_discount == 'yes'){
- $lot_discount_quantity = get_post_meta( $product_id, '_lot_discount_quantity', true );
- $lot_discount_percentage = get_post_meta( $product_id, '_lot_discount_amount', true );
- $lot_discount_percentage_two = get_post_meta( $product_id, '_lot_discount_amount_two', true );
- $lot_discount_quantity_two = get_post_meta( $product_id, '_lot_discount_quantity_two', true );
- $lot_discount_percentage_three = get_post_meta( $product_id, '_lot_discount_amount_three', true );
- $lot_discount_quantity_three = get_post_meta( $product_id, '_lot_discount_quantity_three', true );
- $discount_status = get_post_meta($product_id,'_discount_status',true);
- $discount_status_two = get_post_meta($product_id,'_discount_status_two',true);
- $discount_status_three = get_post_meta($product_id,'_discount_status_three',true);
- if($product->get_sale_price()<='0'){
- $price = $product->get_price();
- }else{
- $price = $product->get_sale_price();
- }
- ?>
- <table class="dokan-table dokan-table-striped dokan-inline-editable-table" id="dokan-product-list-table">
- <thead>
- <tr align="center">
- <th>Quantity</th>
- <th>Bulk Purchase Pricing</th>
- </tr>
- </thead>
- <tbody>
- <?php
- if($lot_discount_quantity > 0){
- if($lot_discount_percentage > 0){
- ?>
- <tr align="center">
- <td>
- <?php
- if($lot_discount_quantity_two > $lot_discount_quantity){
- $isi = $lot_discount_quantity_two - 1;
- if($isi == $lot_discount_quantity_two){
- echo $lot_discount_quantity;
- }else if($isi <= 1){
- echo $lot_discount_quantity;
- }else{
- echo $lot_discount_quantity." - ".$isi;
- }
- }else{
- echo $lot_discount_quantity." or more";
- }
- ?>
- </td>
- <td>
- <?php
- if($discount_status == 'percentage'){
- $final = $price - (($lot_discount_percentage/100)*$price);
- echo get_woocommerce_currency_symbol()." ".number_format($final,2);
- }else if($discount_status == 'fixed'){
- echo get_woocommerce_currency_symbol()." ".number_format($lot_discount_percentage);
- }
- ?>
- </td>
- </tr>
- <?php
- }
- if($lot_discount_quantity_two > $lot_discount_quantity){
- if($lot_discount_percentage_two > 0){
- ?>
- <tr align="center">
- <td>
- <?php
- if($lot_discount_quantity_three > $lot_discount_quantity_two){
- //echo $lot_discount_quantity_two." - ". ($lot_discount_quantity_three - 1);
- $isi = $lot_discount_quantity_three - 1;
- if($isi == $lot_discount_quantity_three){
- echo $lot_discount_quantity_two;
- }else if($isi <= '1'){
- echo $lot_discount_quantity_two;
- }else{
- echo $lot_discount_quantity_two." - ".$isi;
- //echo "test";
- }
- }else{
- echo $lot_discount_quantity_two." or more";
- }
- ?>
- </td>
- <td>
- <?php
- if($discount_status == 'percentage'){
- $final = $price - (($lot_discount_percentage_two/100)*$price);
- echo get_woocommerce_currency_symbol()." ".number_format($final,2);
- }else if($discount_status == 'fixed'){
- echo get_woocommerce_currency_symbol()." ".number_format($lot_discount_percentage_two);
- }
- ?>
- </td>
- </tr>
- <?php
- }
- }
- if($lot_discount_quantity_three > $lot_discount_quantity_two){
- if($lot_discount_percentage_three > 0){
- ?>
- <tr align="center">
- <td>
- <?php
- echo $lot_discount_quantity_three." or more";
- ?>
- </td>
- <td>
- <?php
- if($discount_status == 'percentage'){
- $final = $price - (($lot_discount_percentage_three/100)*$price);
- echo get_woocommerce_currency_symbol()." ".number_format($final,2);
- }else if($discount_status == 'fixed'){
- echo get_woocommerce_currency_symbol()." ".number_format($lot_discount_percentage_three);
- }
- ?>
- </td>
- </tr>
- <?php
- }
- }
- }?>
- </tbody>
- </table>
- <?php
- }
- }
- //add_action('woocommerce_cart_totals_before_order_total','show_lot_discount');
- add_action('woocommerce_before_add_to_cart_form','show_lot_discount');
- //add_action('woocommerce_product_meta_end','show_lot_discount');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement