Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: MODUL: Plus / Minus Buttons bei Warenkorb Button

    RobtheTop

    • Schreiberling
    • Beiträge: 332
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #75 am: 04. März 2021, 22:00:40
    Hallo ich habe das Modul jetzt auch mal einbauen wollen, aber irgendwie tut sich gar nichts bei mir.

    Es sieht alles aus wie vorher. Weder + noch - Button sind vorhanden.
    Ich nutze Shopversion 2.0.5.1 mit dem responsive Template

    Hier meine /templates/tpl_modified_responsive/javascript/general.js.php

    Code: PHP  [Auswählen]
    <?php
    /*-----------------------------------------------------------
       $Id:$

       modified eCommerce Shopsoftware
       http://www.modified-shop.org

       Copyright (c) 2009 - 2013 [www.modified-shop.org]
      -----------------------------------------------------------
       based on: (c) 2003 - 2006 XT-Commerce (general.js.php)
      -----------------------------------------------------------
       Released under the GNU General Public License
       -----------------------------------------------------------
    */

    define('DIR_TMPL_JS', DIR_TMPL.'javascript/');
    // this javascriptfile get includes at the TOP of every template page in shop
    // you can add your template specific js scripts here
    ?>
    <script type="text/javascript">var DIR_WS_BASE="<?php echo DIR_WS_BASE ?>"</script>
    <?php
    // BOF - buttons increment/decrement
    if (strstr($PHP_SELF, FILENAME_PRODUCT_INFO)) {
    ?>
    <script type="text/javascript">
    /* <![CDATA[ */
    $(function(){
      $("input[name='products_qty']").attr('readonly', 'readonly').val(<?php echo $info_smarty->get_template_vars('PRODUCTS_QUANTITY'); ?><1?0:1).before('<a id="inc" class="btn-plus">+</a> ').after(' <a id="dec" class="btn-minus">&ndash;</a>');
      $(".addtobasket_qty").css('width', 'auto')
      $("#inc, #dec").click(function() {
        var oldValue = parseInt($(this).parent().find("input[name='products_qty']").val());
        if ($(this).attr("id") == "inc") {
           if (oldValue > 0) {
               var newVal = oldValue + 1;
           } else {
               newVal = 1;
           }
        } else {
           // Don't allow decrementing below 1
           if (oldValue > 1) {
               var newVal = oldValue - 1;
           } else {
               newVal = 1;
           }
        }

        $(this).parent().find("input[name='products_qty']").val(Math.min(newVal, (<?php echo $info_smarty->get_template_vars('PRODUCTS_QUANTITY'); ?><0?0:<?php echo $info_smarty->get_template_vars('PRODUCTS_QUANTITY'); ?>)));
      });
    });
    /*]]>*/
    </script>  
    <style>
    #inc {
      float: left;
      height: 26px;
      background: #686666;
      font-family: Arial;
      color: #ffffff;
      font-size: 18px;
      padding: 4px 7px 0 7px;
      text-decoration: none;
    }

    #dec {
      float: left;
      height: 24px;
      background: #686666;
      font-family: Arial;
      color: #ffffff;
      font-size: 14px;
      font-weight: bold;
      padding: 6px 8px 0 8px;
      text-decoration: none;
    }

    #inc:hover, #dec:hover {
      background: #828082;
      color: #ffffff;
      cursor: pointer;
      text-decoration: none;
    }
    </style>
    <?php
    }
    // EOF - buttons increment/decrement
    ?>

     

    Dankeschön

    Q

    • Fördermitglied
    • Beiträge: 1.502
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #76 am: 05. März 2021, 08:16:26
    Hast du den CSS Anteil auch erledigt?

    RobtheTop

    • Schreiberling
    • Beiträge: 332
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #77 am: 05. März 2021, 09:48:16
    Wie meinst du das "erledigt"
    Der CSS code ist doch im Code oben eingebettet, oder nicht?

    RobtheTop

    • Schreiberling
    • Beiträge: 332
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #78 am: 05. März 2021, 10:57:47
    Habe den CSS Code nochmal zusätzlich in die template css datei gepackt, aber dennoch nicht.
    Es müssten ohne CSS ja wenigestens das Plus und das Minus zu sehen sein, eben ohne Formatierung, aber selbst das ist nicht der Fall.
    Komisch.
    Kann mir jemand Helfen?

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #79 am: 05. März 2021, 11:08:38
    Hallo RobtheTop,

    weil in der Shopversion 2.0.5.1 beim Template tpl_modified_responsive die Datei /templates/tpl_modified_responsive/javascript/jquery.min.js erst in der Datei /templates/tpl_modified_responsive/javascript/general_bottom.js.php eingefügt wird, musst du den Code am Ende der Datei /templates/tpl_modified_responsive/javascript/general_bottom.js.php einbauen. Ausserdem sollte man das Styling anpassen.

    Gruss
    Hanspeter

    RobtheTop

    • Schreiberling
    • Beiträge: 332
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #80 am: 05. März 2021, 11:53:29
    Danke dir, aber auch das funktioniert irgendwie nicht.

    hier meine general_bottom.js.php

    Code: PHP  [Auswählen]
    <?php
    /*-----------------------------------------------------------
       $Id: general_bottom.js.php 12501 2020-01-08 06:47:31Z GTB $

       modified eCommerce Shopsoftware
       http://www.modified-shop.org

       Copyright (c) 2009 - 2013 [www.modified-shop.org]
      -----------------------------------------------------------
       based on: (c) 2003 - 2006 XT-Commerce (general.js.php)
      -----------------------------------------------------------
       Released under the GNU General Public License
       -----------------------------------------------------------
    */

    // this javascriptfile get includes at the BOTTOM of every template page in shop
    // you can add your template specific js scripts here
    ?>

    <script src="<?php echo DIR_WS_BASE.DIR_TMPL_JS; ?>jquery.min.js" type="text/javascript"></script>
    <?php
    $script_array = array(
      DIR_TMPL_JS.'jquery.colorbox.min.js',
      DIR_TMPL_JS.'jquery.unveil.min.js',
      DIR_TMPL_JS.'jquery.bxslider.min.js',
      DIR_TMPL_JS.'jquery.cookieconsent.min.js',
      DIR_TMPL_JS.'jquery.easyTabs.min.js',
      DIR_TMPL_JS.'jquery.alertable.min.js',
      DIR_TMPL_JS.'jquery.sumoselect.min.js',
      DIR_TMPL_JS.'jquery.sidebar.min.js',
    );
    /* BOF Module "Attribute Kombination Manager" made by Karl */
    if (defined('MODULE_PRODUCTS_COMBINATIONS_STATUS') && MODULE_PRODUCTS_COMBINATIONS_STATUS == 'true'){
      $script_array[] = DIR_TMPL_JS .'dependent-dropdown.min.js';
      if ($_SESSION["language_code"]=='de') $script_array[] = DIR_TMPL_JS .'depdrop_locale_de.js';
    }
    /* EOF Module "Attribute Kombination Manager" made by Karl */
    $script_min = DIR_TMPL_JS.'tpl_plugins.min.js';
     
    $this_f_time = filemtime(DIR_FS_CATALOG.DIR_TMPL_JS.'general_bottom.js.php');
     
    if (COMPRESS_JAVASCRIPT == 'true') {
      require_once(DIR_FS_BOXES_INC.'combine_files.inc.php');
      $script_array = combine_files($script_array,$script_min,false,$this_f_time);
    }

    foreach ($script_array as $script) {
      $script .= strpos($script,$script_min) === false ? '?v=' . filemtime(DIR_FS_CATALOG.$script) : '';
      echo '<script src="'.DIR_WS_BASE.$script.'" type="text/javascript"></script>'.PHP_EOL;
    }

    ob_start();
    foreach(auto_include(DIR_FS_CATALOG.DIR_TMPL_JS.'/extra/','php') as $file) require ($file);
    $javascript = ob_get_clean();
    if (COMPRESS_JAVASCRIPT == 'true') {
      require_once(DIR_FS_EXTERNAL.'compactor/compactor.php');
      $compactor = new Compactor(array('strip_php_comments' => false, 'compress_css' => false, 'compress_scripts' => true));
      $javascript = $compactor->squeeze($javascript);
    }
    echo $javascript.PHP_EOL;

    if (strstr($PHP_SELF, FILENAME_CONTENT) && isset($_GET['coID']) && $_GET['coID'] == 8) {
    ?>
    <!--[if lt IE 10]>
    <script src="<?php echo DIR_WS_BASE.DIR_TMPL_JS; ?>jquery.css3-multi-column.js"></script>
    <![endif]-->
    <?php
    }
    ?>
    <script type="text/javascript">
    /* <![CDATA[ */
      var quantity = parseInt({$PRODUCTS_QUANTITY});
      {literal}
        $(document).ready(function(){
          var item = $("input[name='products_qty']");
          item.before('<a id="inc" class="btn-plus">+</a> ').after(' <a id="dec" class="btn-minus">&ndash;</a>');
          $("#inc, #dec").click(function() {
            var oldVal = parseInt($(this).parent().find("input[name='products_qty']").val());
            if ($(this).attr("id") == "inc") {
              var newVal = (oldVal > 0 ? (oldVal + (oldVal < quantity ? 1 : 0)) : 1);
            } else {
              var newVal = (oldVal > 1 ? (oldVal - 1) : 1);
            }
            $(this).parent().find("input[name='products_qty']").val(newVal);
          });
          item.focusout(function() {
            var val = parseInt($(this).val());
            if (val > quantity) {
              $(this).val(quantity);
            } else if (!val || val < 1) {
              $(this).val(1);
            }
          });
        });
      {/literal}
    /*]]>*/
    </script>
     

    Den CSS code habe ich in die template css datei gepackt,
    hatte ihn aber auch schon in der general_bottom.js.php, aber beide varianten haben nicht funktioniert.

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #81 am: 05. März 2021, 11:58:41
    Du hast den falschen Code eingebaut, folgenden musst du einbauen.

    Code: PHP  [Auswählen]
    <?php
    // BOF - buttons increment/decrement
    if (strstr($PHP_SELF, FILENAME_PRODUCT_INFO)) {
    ?>
    <script type="text/javascript">
    /* <![CDATA[ */
    $(function(){
      $("input[name='products_qty']").attr('readonly', 'readonly').val(<?php echo $info_smarty->get_template_vars('PRODUCTS_QUANTITY'); ?><1?0:1).before('<a id="inc" class="btn-plus">+</a> ').after(' <a id="dec" class="btn-minus">&ndash;</a>');
      $(".addtobasket_qty").css('width', 'auto')
      $("#inc, #dec").click(function() {
        var oldValue = parseInt($(this).parent().find("input[name='products_qty']").val());
        if ($(this).attr("id") == "inc") {
           if (oldValue > 0) {
               var newVal = oldValue + 1;
           } else {
               newVal = 1;
           }
        } else {
           // Don't allow decrementing below 1
           if (oldValue > 1) {
               var newVal = oldValue - 1;
           } else {
               newVal = 1;
           }
        }

        $(this).parent().find("input[name='products_qty']").val(Math.min(newVal, (<?php echo $info_smarty->get_template_vars('PRODUCTS_QUANTITY'); ?><0?0:<?php echo $info_smarty->get_template_vars('PRODUCTS_QUANTITY'); ?>)));
      });
    });
    /*]]>*/
    </script>  
    <style>
    #inc {
      float: left;
      height: 26px;
      background: #686666;
      font-family: Arial;
      color: #ffffff;
      font-size: 18px;
      padding: 4px 7px 0 7px;
      text-decoration: none;
    }

    #dec {
      float: left;
      height: 24px;
      background: #686666;
      font-family: Arial;
      color: #ffffff;
      font-size: 14px;
      font-weight: bold;
      padding: 6px 8px 0 8px;
      text-decoration: none;
    }

    #inc:hover, #dec:hover {
      background: #828082;
      color: #ffffff;
      cursor: pointer;
      text-decoration: none;
    }
    </style>
    <?php
    }
    // EOF - buttons increment/decrement
    ?>

    [...]
    Den CSS code habe ich in die template css datei gepackt,
    [...]

    Das ist mit obigem Code nicht nötig.

    Gruss
    Hanspeter

    RobtheTop

    • Schreiberling
    • Beiträge: 332
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #82 am: 05. März 2021, 12:03:35
    ahhhh.

    Code: PHP  [Auswählen]
    <?php
    // BOF - buttons increment/decrement
    if (strstr($PHP_SELF, FILENAME_PRODUCT_INFO)) {
    ?>

    Hat gefehlt, richtig?

    Da hab ich beim Kopieren anscheindend was falsch gemacht.
    Jetzt gehts.
    Vielen lieben Dank

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #83 am: 05. März 2021, 12:23:55
    Nicht nur das

    Code: PHP  [Auswählen]
    <?php
    // BOF - buttons increment/decrement
    if (strstr($PHP_SELF, FILENAME_PRODUCT_INFO)) {
    ?>

    hat gefehlt, sondern den Code den du eingebaut hast ist für eine Smarty-Template Datei geschrieben, siehe {literal} im Code.

    Gruss
    Hanspeter

    RobtheTop

    • Schreiberling
    • Beiträge: 332
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #84 am: 05. März 2021, 13:02:47
    Alles klar, danke.
    Darauf habe ich nicht geachtet.

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.743
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #85 am: 05. März 2021, 13:31:32
    *Klugsch...-Modus an*

    Das
    Code: PHP  [Auswählen]
    <?php
    // BOF - buttons increment/decrement
    if (strstr($PHP_SELF, FILENAME_PRODUCT_INFO)) {
    ?>

    sollte man aus Geschwindigkeitsgründen so schreiben
    Code: PHP  [Auswählen]
    <?php
    // BOF - buttons increment/decrement
    if (strpos($PHP_SELF, FILENAME_PRODUCT_INFO) !== false) {
    ?>

    oder gar so
    Code: PHP  [Auswählen]
    <?php
    // BOF - buttons increment/decrement
    if (basename($PHP_SELF) == FILENAME_PRODUCT_INFO) {
    ?>

    *Klugsch...-Modus aus*

    Gruß,
    noRiddle

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #86 am: 05. März 2021, 13:37:15
    Kann den Geschwindigkeitsvorteil nicht erkennen.

    Begründung?

    Gruss
    Hanspeter

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.743
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #87 am: 05. März 2021, 13:39:41
    Note:
    If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.

    Gruß,
    noRiddle

    *NACHTRAG*
    Gibt im I-Net auch irgendwo Benchmarks dazu...

    hpzeller

    • Experte
    • Beiträge: 4.129
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #88 am: 05. März 2021, 13:57:23
    Schätzte das steht dort schon seit zwanzig Jahren, heute sind sind die Rechner etwa tausendmal schneller als damals. Wenn der Geschwindigkeitsvorteil zwei oder drei millionstel Sekunden beträgt braucht einem das kaum zu interessieren.

    Gruss
    Hanspeter

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.743
    • Geschlecht:
    Re: MODUL: Plus / Minus Buttons bei Warenkorb Button
    Antwort #89 am: 05. März 2021, 15:13:21
    Jau, war auch keine Kritik im absoluten Sinne, deshalb ja auch "*Klugsch...-Modus*".
    Ich würde trotzdem an jeder Stelle wo es geht die Performance optimieren, das summiert sich nämlich am Ende doch, zumal es hier nicht nur um Geschwindigkeit sondern auch um Memory geht.

    Gruß,
    noRiddle
    Trade Republic - Provisionsfrei Aktien handeln
    15 Antworten
    11903 Aufrufe
    07. April 2019, 10:53:17 von hexenkesselchen
    1 Antworten
    2926 Aufrufe
    02. Januar 2014, 18:33:51 von sv.brueck
    5 Antworten
    3755 Aufrufe
    30. Januar 2013, 13:31:05 von jannemann
               
    anything