Shop: Alert box when no option is selected

Hier bekommst Du deutschsprachigen Support bezüglich offizieller Module für phpwcms. Keine Fehlermeldungen oder Erweiterungswünsche bitte!
Post Reply
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Shop: Alert box when no option is selected

Post by update »

Wenn ich im Shop einen Artikel mit Optionen habe und einfach auf "in den Warenkorb" klicke, ohne eine Option ausgewählt zu haben, dann wird der Artikel ohne weitere Ansage nicht in den Korb gelegt.
Da wäre es natürlich schön, einen Hinweis zu bekommen, dass noch die Auswahl fehlt...
Wie könnte man das erreichen? Jemand ne Idee?
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
Oliver Georgi
Site Admin
Posts: 9888
Joined: Fri 3. Oct 2003, 22:22
Contact:

Re: Shop: Alert box when no option is selected

Post by Oliver Georgi »

per JavaScript abfangen, benötigt sinnvollerweise aktuellen Commit (https://github.com/slackero/phpwcms/commits/dev-1.x)

Code: Select all

$(function() {
    $('form.product-cart-option').submit(function(event) {
        event.preventDefault();
        var $this = $(this);
        var opt1 = $('select.product-option-1', $this);
        var opt2 = $('select.product-option-2', $this);
        if(opt1.length && opt2.length) {
            var opt1_value = opt1.val();
            var opt2_value = opt2.val();
            if(!opt1_value || opt1_value == '0' || !opt2_value || opt2_value == '0') {
                alert('Select product options');
                return false;
            }
        } else if(opt1.length) {
            var opt1_value = opt1.val();
            if(!opt1_value || opt1_value == '0') {
                alert('Select product option 1');
                return false;
            }
        }  else if(opt2.length) {
           var opt2_value = opt2.val();
            if(!opt2_value || opt2_value == '0') {
                alert('Select product option 2');
                return false;
            }
        }

        $this.submit();
    });
});
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Shop: Alert box when no option is selected

Post by update »

hab's leider nicht hinbekommen. Wo genau gehört das JS denn hin?
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
Oliver Georgi
Site Admin
Posts: 9888
Joined: Fri 3. Oct 2003, 22:22
Contact:

Re: Shop: Alert box when no option is selected

Post by Oliver Georgi »

egal wo, gebraucht in Produktliste/-detail.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Post Reply