Jump to content

suhy

Members
  • Content count

    97
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    suhy got a reaction from oscMarket in [Contribution] Quantity Discounts by That Software Guy   
    Hello !
     
    This is probably the easiest contribution to apply some dynamic discount option to order total and I love it for my heavy modified shop :D
     
    So, I have made a little addon for it when using % rate discount with order total amount. Thought it would be nice to show a customer which level of discount he already achieved and of course he must also see how little gap there is to the next level if any. It may boost the order for a few € ;).
     
    Please also note above post for TAX settings. I'm using SPPC and the way to set it is TAX inclusive and recalculate tax and select tax class, so also tax exclusions works fine.
     
    The addon grabs the Discount level and Discount Amount from database as set in admin module, for all 5 levels.
    Then we play with some ifs and css classes to display it dinamicaly in relation to order total amount ...
    I placed it under the shopping cart box as its cool to be always visible where right column is visible also ..
     
    It could probably be done in another, maybe simpler way, but these are my current coding skills, still learning, any suggestion appriciated :).
     
    To avoid some additional code, please respect the following !:
    - Dont skip levels. Levels NOT in use should be at the end. If you delete level 3 for example, than move level 4 to 3 and 5 to 4 and leave level 5 empty.
    - Its kind of logical this way, but you never know.. If you skip levels, css breaks, no need for extra conditions, we have a rule now :D
    This is a simple way for css to work fine as we have to move discount indicator up down within levels limits and stll watch for not activated levels.
    Example: level 3 can also be the last level of course, it would not display properly if the order total is higher than the level 3 limits, but if we know its the last level to show, we also now that level 4 is null in this case ....so we add another check for if llevel = null and if yes, we can set behaviour as the last level ... I had a feeling that I have to explain this :/
     
    Here's a short video of addon in action :

    https://youtu.be/C6I8vlrDLxA
     
     
    Hope that somebody finds it as useful as I do :D
     
    Installation proceedure: oscommerce 2.3.4
     
    1#
    Install original contribution
     
    2#
    catalog/includes/modules/boxes/bm_shopping_cart.php
     
    find:
    $data = '<div class="ui-widget infoBoxContainer">' . ' <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . MODULE_BOXES_SHOPPING_CART_BOX_TITLE . '</a></div>' . ' ' . $cart_contents_string . '</div>'; replace with:
    $data = '<div class="ui-widget infoBoxContainer mj-shoppingcart">' . ' <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . MODULE_BOXES_SHOPPING_CART_BOX_TITLE . '</a></div>' . ' ' . $cart_contents_string . ''; /* suhi */ $suhi_total_box = ($cart->show_total()); $popust_class = "popust_levl_met"; $suhi_query = tep_db_query("select (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_1') AS popust_nivo_1, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_2') AS popust_nivo_2, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_3') AS popust_nivo_3, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_4') AS popust_nivo_4, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_LEVEL_5') AS popust_nivo_5, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_AMOUNT_1') AS popust_nivo_proc1, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_AMOUNT_2') AS popust_nivo_proc2, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_AMOUNT_3') AS popust_nivo_proc3, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_AMOUNT_4') AS popust_nivo_proc4, (select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_AMOUNT_5') AS popust_nivo_proc5 "); $suhi_popust = tep_db_fetch_array($suhi_query); $popust_nivo_1 = $suhi_popust['popust_nivo_1']; $popust_nivo_2 = $suhi_popust['popust_nivo_2']; $popust_nivo_3 = $suhi_popust['popust_nivo_3']; $popust_nivo_4 = $suhi_popust['popust_nivo_4']; $popust_nivo_5 = $suhi_popust['popust_nivo_5']; $popust_nivo_proc1 = $suhi_popust['popust_nivo_proc1']; $popust_nivo_proc2 = $suhi_popust['popust_nivo_proc2']; $popust_nivo_proc3 = $suhi_popust['popust_nivo_proc3']; $popust_nivo_proc4 = $suhi_popust['popust_nivo_proc4']; $popust_nivo_proc5 = $suhi_popust['popust_nivo_proc5']; if ($popust_nivo_proc1 > 0) { $data .= '<div class="shopping_cart_box_discount_note"><div class="popust_shop_box_heading"><div>'. SUHI_TEXT_SHOP_BOX_DISC_NOTE .'</div><a class="popust_info" href="#" data-tooltip data-tooltip-label="'. TEXT_TOOLTIP_DISCOUNT_INFO_HEADER .'" data-tooltip-message="'. TEXT_TOOLTIP_DISCOUNT_INFO_MESSAGE .'"><img src="images/icons/info_icon_blue.png" alt="popust za vaš nakup" /></a></div>'; if ($popust_nivo_proc1 > 0) { if ((($suhi_total_box > $popust_nivo_1) & ($suhi_total_box < $popust_nivo_2)) || (($suhi_total_box > $popust_nivo_1) & ($popust_nivo_2 == null))) { $data .= '<div class="'. $popust_class .'">'. $popust_nivo_proc1 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_1 .' € <span class="tvoj_popust">'. BOX_POPUSTI_VAS_POPUST .'</span></div>'; } else { $data .= '<div class="popust_off">'. $popust_nivo_proc1 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_1 .' €</div>'; } } if ($popust_nivo_proc2 > 0) { if ((($suhi_total_box > $popust_nivo_2) & ($suhi_total_box < $popust_nivo_3)) || (($suhi_total_box > $popust_nivo_2) & ($popust_nivo_3 == null))) { $data .= '<div class="'. $popust_class .'">'. $popust_nivo_proc2 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_2 .' € <span class="tvoj_popust">'. BOX_POPUSTI_VAS_POPUST .'</span></div>'; } else { $data .= '<div class="popust_off">'. $popust_nivo_proc2 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_2 .' €</div>'; } } if ($popust_nivo_proc3 > 0) { if ((($suhi_total_box > $popust_nivo_3) & ($suhi_total_box < $popust_nivo_4)) || (($suhi_total_box > $popust_nivo_3) & ($popust_nivo_4 == null))) { $data .= '<div class="'. $popust_class .'">'. $popust_nivo_proc3 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_3 .' € <span class="tvoj_popust">'. BOX_POPUSTI_VAS_POPUST .'</span></div>'; } else { $data .= '<div class="popust_off">'. $popust_nivo_proc3 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_3 .' €</div>'; } } if ($popust_nivo_proc4 > 0) { if ((($suhi_total_box > $popust_nivo_4) & ($suhi_total_box < $popust_nivo_5)) || (($suhi_total_box > $popust_nivo_4) & ($popust_nivo_5 == null))) { $data .= '<div class="'. $popust_class .'">'. $popust_nivo_proc4 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_4 .' € <span class="tvoj_popust">'. BOX_POPUSTI_VAS_POPUST .'</span></div>'; } else { $data .= '<div class="popust_off">'. $popust_nivo_proc4 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_4 .' €</div>'; } } if ($popust_nivo_proc5 > 0) { if ($suhi_total_box > $popust_nivo_5) { $data .= '<div class="'. $popust_class .'">'. $popust_nivo_proc5 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_5 .' € <span class="tvoj_popust">'. BOX_POPUSTI_VAS_POPUST .'</span></div>'; } else { $data .= '<div class="popust_off">'. $popust_nivo_proc5 .'% '. POPUSTI_BOX_NAD .' '. $popust_nivo_5 .' €</div>'; } } $data .= '</div>'; } /* end suhi */ catalog/includes/languages/english.php
     
    add atthe end, before last    ?>
    /* ********************************* */ define('POPUSTI_BOX_NAD','over'); define('BOX_POPUSTI_VAS_POPUST','Your Discount'); define('SUHI_TEXT_SHOP_BOX_DISC_NOTE','YOUR DISCOUNT'); define('TEXT_TOOLTIP_DISCOUNT_INFO_MESSAGE','Take advantage of our Discount Ladder. You get more discount by spending more !'); define('TEXT_TOOLTIP_DISCOUNT_INFO_HEADER','DISCOUNT Info'); /* ********************************* */ add to your stylesheet:
    /* discounts */ /* shopping cart box */ .popust_levl_met { color:#DB2523; font-weight:700; background:#FEE9C5 url(../../images/icons/ok_icon_green_small.png) no-repeat left; padding:2px 0 2px 30px; } div.shopping_cart_box_discount_note { margin-bottom:20px; border-bottom:1px solid #d8d8d8; padding-bottom:5px; } .popust_off { padding-left:30px; } .popust_shop_box_heading { background-color:#9E0000; font-weight:700; padding:8px 0 8px 8px; color:#ffffff; border:4px solid #870000; margin-bottom:10px; } .popust_shop_box_heading div { width:175px; float:left; } .popust_shop_box_heading img{ height:22px; } .tvoj_popust { color:#212121; font-weight:normal; text-align:right; font-size:12px; margin-left:10px; background-color:#FFCC6F; padding:5px 4px 3px 4px; } /* tooltips */ a.popust_info { color: #5EC7F6; clear:both; } [data-tooltip] { position: relative; } [data-tooltip]:before, [data-tooltip]:after { display: none; position: absolute; top: 0; } [data-tooltip]:before { border-bottom: .6em solid #09f; border-bottom: .6em solid rgba(0,153,255,0.8); border-left: 7px solid transparent; border-right: 7px solid transparent; content: ""; left: -20px; margin-top: 1em; } [data-tooltip]:after { background-color: #0099ff; background-color: rgba(0,153,255,0.8); border: 4px solid #0099ff; border: 4px solid rgba(0,153,255,0.8); border-radius: 7px; color: #ffffff; content: attr(data-tooltip-label) ":\A" attr(data-tooltip-message); left: -150px; margin-top: 1.5em; padding: 5px 15px; white-space: pre-wrap; width: 160px; font-weight:700; } [data-tooltip]:hover:after, [data-tooltip]:hover:before { display: block; } There are also 2 new images:
    images/icons/ok_icon_green_small.png  // 23x20 px (3px transparent on left to add some space on the left, )
    images/icons/info_icon_blue.png  // defined in css to 22px height
     
    And that's it. Change CSS and these 2 images to fit your look & feel ...
     
    I'm almost sure I didn't forget anything :-
     
    Have fun and cheers from Ljubljana,
    Gregor


×