сделал скидку в зависимости от суммы в корзине, но остался небольшой штрих..:(

Discussion in 'Хаки и модификации' started by yurokkk, Mar 21, 2009.

  1. Offline

    yurokkk Недавно здесь

    Joined:
    Mar 19, 2009
    Messages:
    3
    Likes Received:
    0
    делал как тут:
    http://www.designtoeclipse.co.uk/index.php/Leeds-Yorkshire-UK-Web-Design-Hints-and-Tiips/Virtuemart-e-commerce-system/Virtuemart-a-mod-to-allow-discount-based-on-shopping-bag-total.html

    The Virtuemart ecommerce system for Joomla does not allow, as standard the application of a discount based on the total value of the shopping cart.



    This method will deliver this functionality.



    As always make sure you have a back up of any file before you make changes!!!



    Virtuemart and Joomla are both open sourced projects. The benefit of this is that fixes like this can be readily developed by the worldwide community of users and developers.



    Detailed instructions are found below.








    Step 1. Added this to english.php

    /**New for global discount*****/

    var $_PHPSHOP_GLOBAL_DISCOUNT = 'Global Product Discount';
    var $_PHPSHOP_GLOBAL_DISCOUNT_INFO = 'Enter your global product discount in decimals. This discount will be applied to products in your shopping cart at the time of checkout';

    var $_PHPSHOP_GLOBAL_DISCOUNTABOVE = 'Global Product Discount Minimum Cart Value';
    var $_PHPSHOP_GLOBAL_DISCOUNT_ABOVEINFO = 'Enter your global product discount start level in decimals. The discount will be applied when your shopping cart exceeds this amount at the time of checkout';


    /**End of New for global discount*****/

    Step 2. ps_config.php added below line $my_config_array = array(

    /***New for global discount***/

    "GLOBAL_DISCOUNT" => "conf_GLOBAL_DISCOUNT",
    "GLOBAL_DISCOUNTABOVE" => "conf_GLOBAL_DISCOUNTABOVE",

    /***End New for Global Discount***/

    Step 3. In admin.show_cfg.php around line 120 added this (So that I could have a text box in the Price Configuration of the VM Global Configuration.)

    /**New for Global discount**/

    <tr>
    <td class="labelcell"><label for="_VM_GLOBAL_DISCOUNT"><?php echo $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNT ?> </label></td>
    <td><input type="text" name="conf_GLOBAL_DISCOUNT" class="inputbox" value="<?php echo GLOBAL_DISCOUNT ?>" /></td>
    <td><?php echo mm_ToolTip( $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNT_INFO ) ?></td>
    </tr>

    <tr>
    <td class="labelcell"><label for="_VM_GLOBAL_DISCOUNTABOVE"><?php echo $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNTABOVE ?> </label></td>
    <td><input type="text" name="conf_GLOBAL_DISCOUNTABOVE" class="inputbox" value="<?php echo GLOBAL_DISCOUNTABOVE ?>" /></td>
    <td><?php echo mm_ToolTip( $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNT_ABOVEINFO ) ?></td>
    </tr>

    /**End New for Global discount**/

    Step 4. In basket.php below $product_rows = Array(); added

    // Added for Global Discount
    $disc = GLOBAL_DISCOUNT;
    $disc_2 = $disc/100;
    $disc_1 = 1-$disc_2;
    $discabove = GLOBAL_DISCOUNTABOVE;
    $discadded=0;
    $discstate="";
    //End added for global discount

    Step 5. basket.php around line 161 just below } // End of for loop through the Cart

    I added

    /******Add code here to change total by percent if above £value*****/
    if ($total>=$discabove) {
    $total = $total*$disc_1;
    $discadded=1;
    $discstate = "YOU HAVE RECIEVED A " . $disc . " % DISCOUNT!!";
    }
    /****end discounting mod******/

    Step 6. basket.php around line 161 just above $tax_total += $shipping_tax;

    I added

    /******Add code here to change total by percent if above £value*****/
    if ($discadded = 1) {
    $tax_total = $tax_total*$disc_1;

    }
    /****end discounting mod******/

    to adjust the tax just before adding shipping


    Step 7. In basket_b2c.html.php around line 70 added this (this flags a message to a user when they update the basket to take value above the preset level for application of discount.

    <!-- added for global discount -->
    <h3><strong><?php echo $discstate; ?> </strong></h3>

    <!-- end added for global discount -->

    все сделал, в basket_b2c.html.php поправил чтобы выводилась надпись о скидке если она есть, НО!
    когда нажать "Оформить заказ"
    то цена получается в следующем шаге БЕЗ СКИДКИ:(
    как поправить?
    [​IMG]
    вот этот шаг где неправильно - не считается скидка:(
    [​IMG]
     
  2.  
  3. beagler
    Offline

    beagler Недавно здесь

    Joined:
    Sep 26, 2006
    Messages:
    19
    Likes Received:
    0
    Gender:
    Male
    такие же изменения как в basket.php нужно делать в ro_basket.php и как в basket_b2c.html.php - в ro_basket_b2c.html.php
    Там весь заказ просчитывается поновой.
     
  4. Offline

    FRITZ Недавно здесь

    Joined:
    Mar 21, 2008
    Messages:
    7
    Likes Received:
    0
    Gender:
    Male
    Сделал всё по этой инструкции http://www.designtoeclipse.co.uk/index.php/Leeds-Yorkshire-UK-Web-Design-Hints-and-Tiips/Virtuemart-e-commerce-system/Virtuemart-a-mod-to-allow-discount-based-on-shopping-bag-total.html но в админке в заказах сумма оставалась без скидки. Поэтому я дописал в файл ps_checkout.php ещё одну строчку для подсчёта скидки. Короче выкладываю этот же мануал но на русском и с мои последним добавлением:



    Шаг 1. Добавляем это в russian.php после class vmLanguage extends vmAbstractLanguage {

    /** GLOBAL DISCOUNT **/

    var $_PHPSHOP_GLOBAL_DISCOUNT = 'Скидка';
    var $_PHPSHOP_GLOBAL_DISCOUNT_INFO = 'Введите скидку на товар (только цифры). Т.е. если скидка 10% введите 10.';

    var $_PHPSHOP_GLOBAL_DISCOUNTABOVE = 'Минимальная сумма для действия скидки';
    var $_PHPSHOP_GLOBAL_DISCOUNT_ABOVEINFO = 'Введите минимальную сумму для действия скидки (только цифры).';

    /**End of GLOBAL DISCOUNT **/


    Шаг 2. В файле ps_config.php после строки $my_config_array = array( добавляем:

    /** GLOBAL DISCOUNT **/

    "GLOBAL_DISCOUNT" => "conf_GLOBAL_DISCOUNT",
    "GLOBAL_DISCOUNTABOVE" => "conf_GLOBAL_DISCOUNTABOVE",

    /** End of GLOBAL DISCOUNT **/


    Шаг 3. В admin.show_cfg.php в конце между $tabs->endTab(); и $tabs->endPane(); добавляем: (таким образом в глобальной конфигурации виртуемарта добавится ещё одна

    вкладка, в которой будет задана скидка)

    /** GLOBAL DISCOUNT **/

    $tabs->startTab( "Скидка \"от суммы заказа\"", "globaldiscount-page");
    ?>
    <table class="adminform">
    <?php ?>
    <tr>
    <td class="labelcell"><label for="_VM_GLOBAL_DISCOUNT"><?php echo $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNT ?> </label></td>
    <td style="width:100px;"><input style="width:60px;" type="text" name="conf_GLOBAL_DISCOUNT" class="inputbox" value="<?php echo GLOBAL_DISCOUNT ?>" />%

    </td>
    <td><?php echo mm_ToolTip( $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNT_INFO ) ?></td>
    </tr>

    <tr>
    <td class="labelcell"><label for="_VM_GLOBAL_DISCOUNTABOVE"><?php echo $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNTABOVE ?> </label></td>
    <td style="width:100px;"><input style="width:60px;" type="text" name="conf_GLOBAL_DISCOUNTABOVE" class="inputbox" value="<?php echo

    GLOBAL_DISCOUNTABOVE ?>" /></td>
    <td><?php echo mm_ToolTip( $VM_LANG->_PHPSHOP_GLOBAL_DISCOUNT_ABOVEINFO ) ?></td>
    </tr>

    <?php ?>
    </table>
    <?php
    $tabs->endTab();

    /** End of GLOBAL DISCOUNT **/


    Шаг 4. В basket.php после $product_rows = Array(); добавляем:

    /** GLOBAL DISCOUNT **/
    $disc = GLOBAL_DISCOUNT;
    $disc_2 = $disc/100;
    $disc_1 = 1-$disc_2;
    $discabove = GLOBAL_DISCOUNTABOVE;
    $discadded=0;
    $discstate="";
    /** End of GLOBAL DISCOUNT **/


    а после } // End of for loop through the Cart добавляем:

    /** GLOBAL DISCOUNT **/
    if ($total>=$discabove) {
    $total = $total*$disc_1;
    $discadded=1;
    $discstate = "ВЫ ПОЛУЧИЛИ СКИДКУ " . $disc . "%!!";
    }
    /** End of GLOBAL DISCOUNT **/


    перед строкой $tax_total += $shipping_tax; добавляем:

    /** GLOBAL DISCOUNT **/
    if ($discadded = 1) {
    $tax_total = $tax_total*$disc_1;
    }
    /** End of GLOBAL DISCOUNT **/


    такие же изменения надо сделать с файлом ro_basket.php


    Шаг 5. В basket_b2c.html.php после условия <?php if($discount_after) { } ?> добавляем:

    <?php /** GLOBAL DISCOUNT **/ ?>
    <tr>
    <td colspan="7" align="center" valign="middle"><h3><strong><?php echo $discstate; ?> </strong></h3></td>
    </tr>
    <?php /** End of GLOBAL DISCOUNT **/ ?>


    такие же изменения надо сделать с файлом ro_basket_b2c.html.php


    Мой Дополнительный 6й Шаг. Для того, чтобы в заказах (в админке) сумма была со скидкой.

    В файле ps_checkout.php перед строкой $order_tax *= $discount_factor; добавляем:


    /** GLOBAL DISCOUNT **/

    if ( $order_total >= GLOBAL_DISCOUNTABOVE ) $order_total -= ($order_total*GLOBAL_DISCOUNT)/100;

    /** End of GLOBAL DISCOUNT **/
     
  5. Offline

    Petrovich123 Пользователь

    Joined:
    Feb 24, 2009
    Messages:
    84
    Likes Received:
    1
    Gender:
    Male
    Сделал все по инструкции, но у меня (шаг 5) не срабатывает <?php echo $discstate; ?>.
    Когда вместо $discstate пишу текст, например <?php echo 'СКИДКА'; ?> - выводит СКИДКА, т.е. как я понял просто не видится переменная $discstate.
    И еще: когда покупатель заходит в свою учетную запись и смотрит свой заказ, то он без скидки, а также заказ который отправляется покупателю (и продавцу) приходит заказ без скидки.
    В чем может быть проблема?
     
    Last edited: Nov 14, 2009
  6. Offline

    Petrovich123 Пользователь

    Joined:
    Feb 24, 2009
    Messages:
    84
    Likes Received:
    1
    Gender:
    Male
    Может кто-то поможет с этим вопросом?
     
  7. Offline

    Petrovich123 Пользователь

    Joined:
    Feb 24, 2009
    Messages:
    84
    Likes Received:
    1
    Gender:
    Male
    FRITZ, Может поможешь с этим вопросом?
     
  8. Offline

    Petrovich123 Пользователь

    Joined:
    Feb 24, 2009
    Messages:
    84
    Likes Received:
    1
    Gender:
    Male
    А не в курсе что нужно дописать, чтобы эта скидка распространялась на покупателей которые отнесены ТОЛЬКО к группе -default-???
     
  9. Offline

    askidkin Недавно здесь

    Joined:
    Apr 1, 2009
    Messages:
    11
    Likes Received:
    0
    Gender:
    Male
    для какой версии хак подойдет?, мне надо на 1,1,4 а как знать где файлы лежат, например файлов russian.php много в виртуемарте, можно описать путь к файлам которые нужно править? Спасибо!
     
  10. Offline

    arkasharina Недавно здесь

    Joined:
    Aug 13, 2010
    Messages:
    3
    Likes Received:
    0
    Gender:
    Female


    У меня это файл language.class
    VirtueMart 1.1.5 stable
     
  11. AKopytenko
    Offline

    AKopytenko Russian Joomla! Team Staff Member

    Joined:
    Sep 1, 2011
    Messages:
    1,963
    Likes Received:
    168
    Gender:
    Male
    Неужели кто-то всё ещё мучается с Virtuemart 1.1.*, когда все нужные расширения (фильтры, корзина на одной странице) уже давно есть на VM2.0 ?
     
  12. NeoBlack
    Offline

    NeoBlack Недавно здесь

    Joined:
    Feb 28, 2015
    Messages:
    1
    Likes Received:
    0
    Gender:
    Female
    В файле basket.php добавил строчку выделенного кода - переменную $discstate (awocoupon у меня стоит, потому и перекидки переменной не было как у автора)

    if(empty($_SESSION['coupon_discount'])) $discount_before = $discount_after = false; # awocoupon_code
    $tpl->set_vars( Array(
    'product_rows' => $product_rows,
    'subtotal_display' => $subtotal_display,
    'discount_before' => $discount_before,
    'discount_after' => $discount_after,
    'coupon_display' => $coupon_display,
    'shipping' => $shipping,
    'shipping_display' => $shipping_display,
    'show_tax' => $show_tax,
    'discstate' => $discstate,
    'tax_display' => $tax_display,
    'order_total_display' => $order_total_display,
    ));
    $basket_html = '';

    В шаге 6 надо поменять

    if ( $order_total >= GLOBAL_DISCOUNTABOVE ) $order_total -= ($order_total*GLOBAL_DISCOUNT)/100; на

    if ( $totals['order_total'] >= GLOBAL_DISCOUNTABOVE ) $totals['order_total'] -= ($totals['order_total']*GLOBAL_DISCOUNT)/100;
     
    Last edited: Feb 28, 2015

Share This Page

Loading...