Jump to content

Recommended Posts

I can confirm that I have BS4 (2.3.4.1 CE) and it does work, probably does not look as pretty as it can on BS3 but that's only because it needs a bit more work and  my lack of experience, but it functions well

David


David

Share this post


Link to post
Share on other sites

Hi David,

Looks we have the same problem. Have the addon installed on a test site with BS4 and it also works but missing a few cosmetic elements. I am also not a experienced coder to make it looks like  BS3.

Hoppefully Raiwa will find some time in the near future to make it work for BS4 to.

Share this post


Link to post
Share on other sites
Posted (edited)

Discount Codes v4.4.2 BS works with osC BS4 at least the back end part where you add and register discount codes and the checkout_confirmation part. However it does fail to inject the code from the header tags module into the checkout_payment.php page.
Not sure if this is an issue only on my side though. Clean Edge BS4 and only Discount Codes 4.4.2 BS installed.

There is a javascript code inside the header tags file which checks for certain classes and then inject the code before that.

$('div.contentContainer div.contentText .form-group').parent()

That is why in the install manual it says

Quote

IMPORTANT: Make sure the following original code is present and not altered or uncommented in checkout_payment.php:
           The ht module uses this code as a reference to inject the discount code input field.

Even if I manually add those classes to the checkout_payment.php file or if I alter the javascript code to match the BS4 classes structure it just won't show anything on the payment page.

So I added the whole javascript code at the very bottom of the checkout_payment.php file and now we finally can see the input field BUT! it is placed in the wrong position. No matter what classes you add or what you try to do to get it injected it always shows at the same spot right after the HEADING_TITLE part.
Changing the following code inside  the HT  module does inject the input field but again in the wrong, same, position.

 var $group = 'header_tags';

to this

 var $group = 'footer_scripts';

Not sure what the exact issue is. I haven't touched osC code in a while and I am absolutely not familiar with the changes in the latest Edge version.
I did manage to add the input field by simply hard coding it into the checkout_payment.php file which is as we all know not the best way to do it but until we can figure out why it isn't injecting or injecting in the right place this should do the trick.
(fixed code to match latest BS4 and FontAwesome standards)

FIND

  <hr>
 
  <div class="form-group row">
    <label for="inputComments" class="col-form-label col-sm-4 text-sm-right"><?php echo TABLE_HEADING_COMMENTS; ?></label>
    <div class="col-sm-8">
      <?php
      echo tep_draw_textarea_field('comments', 'soft', 60, 5, $comments, 'id="inputComments" placeholder="' . TABLE_HEADING_COMMENTS . '"');
      ?>
    </div>
  </div>


 ADD BEFORE

<h2><?php echo TEXT_DISCOUNT_CODE; ?></h2>
<div class="col-xs-6 col-sm-3">
    <div class="form-group row">
        <input type="text" class="form-control" name="discount_code" value="<?php echo isset($sess_discount_code) ? $sess_discount_code : ''; ?>" id="discount_code" />
        <span class="form-control-feedback" id="discount_code_status" style="right:0;"></span>
    </div>
</div>

FIND

<?php
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

ADD AFTER

<script type="text/javascript">
    $(document).ready(function () {
        var a = 0;
        discount_code_process();
        $('#discount_code').blur(function () {
            if (a == 0)
                discount_code_process();
            a = 0
        });
        $("#discount_code").keypress(function (event) {
            if (event.which == 13) {
                event.preventDefault();
                a = 1;
                discount_code_process();
            }
        });
        function discount_code_process() {
            if ($("#discount_code").val() != "") {
                $("#discount_code").attr("readonly", "readonly");
                $("#discount_code_status").empty().append('<i class="fas fa-cog fa-spin fa-lg">&nbsp;</i>');
                $.post("discount_code.php", {discount_code: $("#discount_code").val()}, function (data) {
                    data == 1 ? $("#discount_code_status").empty().append('<i class="fas fa-check fa-lg" style="color:#00b100;"></i>') : $("#discount_code_status").empty().append('<i class="fas fa-ban fa-lg" style="color:#ff2800;"></i>');
                    $("#discount_code").removeAttr("readonly");
                });
            }
        }
    });
</script>

@raiwa

Do you have this properly running on a Edge BS4 store? I mean including injected HT module?

Edited by Tsimi

Share this post


Link to post
Share on other sites
Posted (edited)

Hello @Tsimi,

I do have no plans to update add-ons to EDGE BS4 right now. My plans are to wait for the next stable release, CE BS4 or official BS4. I really have no time any more to run constantly behind EDGE updates.

Anyway EDGE BS4 is intended for people who are able to update the add-ons themselve.

Now in the case of discount code, the code breaks on a more serious way than just BS4 tags. So I'll see if I can find some time to bite the bullet and update it.

Beside the change to footer-scripts group, the class selector in the ht-template needs to be changed to the following:

        $('div.contentContainer .form-group').before('<h2><?php echo TEXT_DISCOUNT_CODE; ?></h2><div class="col-xs-6 col-sm-3">\n\

 

As a general suggestion I would use the opportunity to remove the ht-module and replace it by  a hook or better by a content module for the checkout_payment page.

My favorite is a content module because of the following reasons:

+ we use already a content module for shopping cart, more coherency within the add-on
+ content module can beter controlled in admin: module width and sort order (if used with modular checkout)
+ fits perfect with modular checkout
+ stable and independent of core updates/changes or customizations
- needs one line of additional code (content module call) in checkout_payment.php if modular checkout is not used

Your thoughts?

 

Kind regards
Rainer

Edited by raiwa

Share this post


Link to post
Share on other sites
On ‎5‎/‎28‎/‎2019 at 8:09 PM, DAVID3733 said:

I can confirm that I have BS4 (2.3.4.1 CE) and it does work, probably does not look as pretty as it can on BS3 but that's only because it needs a bit more work and  my lack of experience, but it functions well

David

Just to add as I had forgotten, I do also use the modular checkout that Rainer refers to and the discount code works in a live shop


David

Share this post


Link to post
Share on other sites

@Tsimi,

Played with the shopping cart and ht module under EDGE BS4 and got it to show up correct, but couldn't get the validation script to work. I always get unvalidated icon. The same when I tried with your hardcoded solution. Do you have the same issue? Any ideas?

Share this post


Link to post
Share on other sites
Posted (edited)

@raiwa

 

Quote

I do have no plans to update add-ons to EDGE BS4 right now. My plans are to wait for the next stable release, CE BS4 or official BS4

I didn't mean to put more work into your hands. That was not my intention. Just wanted to check if something is wrong on my end.
I couldn't agree more. Updating an add-on for various CE versions is becoming a bit of a pain in the rear. Better wait for a release or more close to final version.
 

Quote

As a general suggestion I would use the opportunity to remove the ht-module and replace it by  a hook or better by a content module for the checkout_payment page.

A content module sounds like a winner to me. Adding one line into a file won't give anyone a hard time and is fairly easy to do.
I thought if it is a simple change of classes inside the javascript code then I could quickly do that but it didn't work for me.

Quote

Played with the shopping cart and ht module under EDGE BS4 and got it to show up correct, but couldn't get the validation script to work. I always get unvalidated icon. The same when I tried with your hardcoded solution. Do you have the same issue?

I do not have those issues.
When I enter the discount code into the input field the check icon or ban icon show up just fine. Even before I changed them to FontAwesome v5.
I only have problems to position the input field in the right spot just before the comments input field as it suppose to be.
I will try to find time during the weekend and reinstall another EDGE BS4 test shop in my local server which btw. runs on PHP 7.1, and give it another try.

Edited by Tsimi

Share this post


Link to post
Share on other sites
11 minutes ago, Tsimi said:

I didn't mean to put more work into your hands. That was not my intention. Just wanted to check if something is wrong on my end.
I couldn't agree more. Updating an add-on for various CE versions is becoming a bit of a pain in the rear. Better wait for a release or more close to final version.
 

No worries, this was a general statement, not opposed to your question 😉

Share this post


Link to post
Share on other sites

Hi,

Same here. With the adjustments made mentioned above it shows in checkout payment but the validation wheel keeps spinning. Also it’s not possible the make any changes to the input field.

Share this post


Link to post
Share on other sites

Thats different, I can make changes and the non validated icon shows always after the spinner.

Share this post


Link to post
Share on other sites
Posted (edited)

@Tsimi, just to be sure, are you testing this on the latest EDGE BS4 and Discount_Codes_4.4.3_BS?

I just repeated installation on latest vanilla EDGE BS4 and the same, input shows, spinner moves, "not validated" icon shows on any code I tried. When I continue to checkout confirmation, no discount code shows up. But discount code is correct registered in session.

EDIT: Was running too fast, I read now the instructions and saw that I forgot like a bloody beginner to add the code to application_top.php. LOL 😂

Edited by raiwa

Share this post


Link to post
Share on other sites

@Tsimi, @MITCH70, @DAVID3733, and all other BS4 users:

Here the BS4 content modules for shoppin_cart.php and checkout_payment.php.

Only the modules and english language files are included. All other files from FROZEN should work.

Make sure to:

- uninstall the discount code ht-module
- remove the hardcoded example Tsimi has posted above (if you have added)
- add the following lines to checkout_payment.php just above the comments section line 226:

  <div class="row">
    <?php echo $oscTemplate->getContent('checkout_payment'); ?>
  </div>

- install the shopping cart and checkout payment content modules

test, test , test

give feedback, please

PS: Maybe some fine tuning of the html output can be added

Tsimi,

I suggest to name the new version "Discount_Codes_5.0.0_BS4" or "Discount_Codes_5.0.0_BS3_BS4" or just leave it in "Discount_Codes_5.0.0_BS" and explain the other stuff in the description?

I would include the generic files in a catalog folder like now and add one folder with the content modules for BS4 and another for BS3. For coherency I would also add a checkout_payment content module for BS3 and remove the ht-module.

Your thoughts?

2.3.4._EDGE_BS4.zip

Share this post


Link to post
Share on other sites

@raiwa

Discount_Codes_5.0.0_BS  sounds good to me. Also separating the BS4 and BS3 stuff by keeping it in separate catalog folders sounds like a good plan.

I will test your files tomorrow, 1:30 AM here now, and get you some feedback asap.

Thanks

Share this post


Link to post
Share on other sites

Hi,

New files did work almost for me. Only in shopping cart its not showing the validation icons and border is different.
Maybe I forgot something and will check the files again.

discount.jpg.08e320165af9b57fdb9c03c6a33836f3.jpgdiscount2.jpg.06c6ae414982aca9eb688ada577d054e.jpg

Share this post


Link to post
Share on other sites
On 5/31/2019 at 8:36 PM, MITCH70 said:

Hi,

New files did work almost for me. Only in shopping cart its not showing the validation icons and border is different.
Maybe I forgot something and will check the files again.

discount.jpg.08e320165af9b57fdb9c03c6a33836f3.jpgdiscount2.jpg.06c6ae414982aca9eb688ada577d054e.jpg

Sorry, yes the template filename need to be updated. Please rename the shopping cart template file from "discount_code.php" to "tpl_cm_sc_discount_code.php"

Share this post


Link to post
Share on other sites

@Tsimi and other testers.

Some more thoughts:

I forgot that the old header tag also includes code to unregister the discount code from the session when a customer logs off. Thinking about it seems to me that this is not rquired. What harm can be done if the discount code keeps session registered? Anyway the discount codes are validated again on each checkout_confirmation load. Also when logging in again a new session is created anyway. Or do I miss something on this?

But if we keep the ht module, we could do the following:

+ move the code from application_top.php to the ht module: one important core modification less
+ we can move the validation script from the content modules to the header tag module: only one copy of the script -> easier  maintenance and update
+ we can keep the session unregister code for any case as in the old version
- one module (ht) more in the package

 

I created the above scenario version hewre it is for testing:

- remove the code in application_top.php
- install the new ht moduel

test, test ,test

give feedback

Thank you

 

Discount_Codes_5.0.0_beta_01.zip

Share this post


Link to post
Share on other sites

@raiwa

Did some testing with the new 5.0.0 BETA files and looks great. Only thing I noticed is that there is no apply button in checkout_payment. Usefull when you don’t want to have the discount input field already visible in shopping_cart I gues.

Again great work !!

Share this post


Link to post
Share on other sites
Posted (edited)

Thank you Mitch for testing. The apply button is only required in shopping cart for to reload the page and show the discount in the ship in cart order total module. But you gave me the idea to link it there to the case when ship in cart ot module is used. Otherwise it is not required there neither.

Edited by raiwa

Share this post


Link to post
Share on other sites

@raiwa

Make sense. But when testing this ill noticed that It does not saves the input given into the number off use field. Also can not enter anything into the number off products to apply field on the admin. One input field color is also darker then the one above.

discount.jpg.35a5fe268ccf93adca94a612a31f1ff6.jpg

Share this post


Link to post
Share on other sites
4 minutes ago, MITCH70 said:

@raiwa

Make sense. But when testing this ill noticed that It does not saves the input given into the number off use field. Also can not enter anything into the number off products to apply field on the admin. One input field color is also darker then the one above.

discount.jpg.35a5fe268ccf93adca94a612a31f1ff6.jpg

@raiwa

Sorry my mistake. Forgot some other needed input fields.

Share this post


Link to post
Share on other sites
Posted (edited)

@Tsimi, @MITCH70,

I played around a bit more and found a solution where the ht module would only be required for the session unregister of the discount code.

The only scenario where this makes sense/is required is the following:

- discount input is allowed for guests/not logged in users in shopping cart

- customer logged in and goes to checkout and introduces a discount code

- he doesn't finish the order logs off and leaves the computer.

- another user uses the same computer/session and goes as a guest to shopping cart, he will see the discount code from the other user which abandoned the checkout.

- if he continues a purchase he can use the discount code which may have not been given to him

Is this a real live problem or just a theorical unperfectness?

EDIT: The same can happen in the old version if input in shopping cart is allowed to guests and the guest introduces a discount code and leaves the computer. Another user can see the code if he uses the computer before session expires.

The complete settings would be:

+ no ht module required

+ application_top.php code moved to discount_code.php file in the root

+ 2 content modules (shopping cart and checkout payment) containing the validation script

+ checkout_process.php code moved into a hook

+ I believe the optional mod for paypal standard can also be hooked, needs to be tested.

Like this the only core changes left would be the content module and hook calls

 

Your thoughts?

Edited by raiwa

Share this post


Link to post
Share on other sites
Posted (edited)

@Tsimi, @MITCH70,

Here the full package Discount Code 5.0.0. beta_02.

For now only EDGE BS4 files included. Once checked and approved I'll add the FROZEN BS3 files. The only difference will be in the content module template files.

Version 5.0.0 BS: Added support for EDGE BS4

  •                   Removed ht-Module
  •                   Moved validation script from ht to content modules
  •                   Moved code from application_top.php into discount_code.php
  •                   Added checkout payment content module to replace code injection in HT module
  •                   Added install warning for required OT modules to content modules
  •                   Added condition to "Apply" button in shopping cart module to show it only if ship in cart Order Totals Module is present.
  •                   Updated templates name to actual naming standard
  •                   Updated templates call in content modules to actual auto inclusion
  •                   Moved html output to content module template files
  •                   Normalized True/False typo in OT module
  •                   Hooked modifications in checkout_process.php and paypal standard files.

 

Installation and Upgrade Instructions are updated. Please try and check the Instructions for errors.

I tested the paypal standard modifications and they work.

 

Discount_Codes_5.0.0_BS_beta_02.zip

Edited by raiwa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×