• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

How to set 'Buy now' button along with Add to card button?

Knowledge Base
5
26
5.5k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    parasbhadauria63 @Vaishali Agarwal last edited by parasbhadauria63 13 Jan 2021, 14:25 13 Jan 2021, 13:57

    @Vaishali-Agarwal
    It is "v1.1.2"

    1 Reply Last reply Reply Quote 0
    • V
      Vaishali Agarwal last edited by 13 Jan 2021, 14:46

      @parasbhadauria63
      I recommend you to upgrade your project with latest release v1.2.0.

      Still you can implement buy now feature on your existing project as well, you just need to update all the changes as mention here https://github.com/bagisto/bagisto/commit/963191b3fc66188f630d0aa34f945b63efcfd48c

      P 1 Reply Last reply 13 Jan 2021, 15:27 Reply Quote 0
      • P
        parasbhadauria63 @Vaishali Agarwal last edited by 13 Jan 2021, 15:27

        @Vaishali-Agarwal
        Ok, How can I upgrade from 1.1.2 to 1.2.0 (latest version).
        Can I upgrade it in one-click as mentioned in https://bagisto.com/en/how-to-update-bagisto-with-one-click/

        1 Reply Last reply Reply Quote 0
        • V
          Vaishali Agarwal last edited by 14 Jan 2021, 15:46

          @parasbhadauria63
          please check this guide if you want to upgrade to latest version https://devdocs.bagisto.com/1.x/introduction/upgrade_to_latest_bagisto.html

          you can't update this with one click update as you have an older version exist in which this feature is not available.

          P 1 Reply Last reply 14 Jan 2021, 16:07 Reply Quote 0
          • P
            parasbhadauria63 @Vaishali Agarwal last edited by 14 Jan 2021, 16:07

            @Vaishali-Agarwal
            The latest version 1.2.0 is installed
            But still, I did not get the option to enable the Buy Now Button

            1 Reply Last reply Reply Quote 0
            • V
              Vaishali Agarwal last edited by 15 Jan 2021, 08:12

              @parasbhadauria63
              If you have successfully installed the latest version then to take the buy now updates you need to done the changes in the files as mention in below link
              https://github.com/bagisto/bagisto/commit/963191b3fc66188f630d0aa34f945b63efcfd48c

              P 1 Reply Last reply 16 Jan 2021, 19:32 Reply Quote 0
              • P
                parasbhadauria63 @Vaishali Agarwal last edited by parasbhadauria63 16 Jan 2021, 20:33 16 Jan 2021, 19:32

                Hi @Vaishali-Agarwal
                I have made the changes as mentioned by you
                I have got the option from the backend as you can see in the screenshot.
                Buy Now Screenshot.png

                Buy Now button becomes visible only in the bliss theme.
                How to make it visible in the Velocity theme also???
                I am sharing some part of the product page source code below:

                <script type='text/javascript' src='https://unpkg.com/spritespin@4.1.0/release/spritespin.js'></script>
                
                <script type="text/x-template" id="product-view-template">
                    <form
                        method="POST"
                        id="product-form"
                        @click="onSubmit($event)"
                        action="http://localhost/bagisto-new/public/checkout/cart/add/1">
                
                        <input type="hidden" name="is_buy_now" v-model="is_buy_now">
                
                        <slot v-if="slot"></slot>
                
                        <div v-else>
                            <div class="spritespin"></div>
                        </div>
                
                    </form>
                </script>
                
                <script>
                    Vue.component('product-view', {
                        inject: ['$validator'],
                        template: '#product-view-template',
                        data: function () {
                            return {
                                slot: true,
                                is_buy_now: 0,
                            }
                        },
                
                        mounted: function () {
                            let currentProductId = 'wall-painting';
                            let existingViewed = window.localStorage.getItem('recentlyViewed');
                
                            if (! existingViewed) {
                                existingViewed = [];
                            } else {
                                existingViewed = JSON.parse(existingViewed);
                            }
                
                            if (existingViewed.indexOf(currentProductId) == -1) {
                                existingViewed.push(currentProductId);
                
                                if (existingViewed.length > 3)
                                    existingViewed = existingViewed.slice(Math.max(existingViewed.length - 4, 1));
                
                                window.localStorage.setItem('recentlyViewed', JSON.stringify(existingViewed));
                            } else {
                                var uniqueNames = [];
                
                                $.each(existingViewed, function(i, el){
                                    if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
                                });
                
                                uniqueNames.push(currentProductId);
                
                                uniqueNames.splice(uniqueNames.indexOf(currentProductId), 1);
                
                                window.localStorage.setItem('recentlyViewed', JSON.stringify(uniqueNames));
                            }
                        },
                
                        methods: {
                            onSubmit: function(event) {
                                if (event.target.getAttribute('type') != 'submit')
                                    return;
                
                                event.preventDefault();
                
                                this.$validator.validateAll().then(result => {
                                    if (result) {
                                        this.is_buy_now = event.target.classList.contains('buynow') ? 1 : 0;
                
                                        setTimeout(function() {
                                            document.getElementById('product-form').submit();
                                        }, 0);
                                    }
                                });
                            },
                        }
                    });
                
                    window.onload = function() {
                        var thumbList = document.getElementsByClassName('thumb-list')[0];
                        var thumbFrame = document.getElementsByClassName('thumb-frame');
                        var productHeroImage = document.getElementsByClassName('product-hero-image')[0];
                
                        if (thumbList && productHeroImage) {
                            for (let i=0; i < thumbFrame.length ; i++) {
                                thumbFrame[i].style.height = (productHeroImage.offsetHeight/4) + "px";
                                thumbFrame[i].style.width = (productHeroImage.offsetHeight/4)+ "px";
                            }
                
                            if (screen.width > 720) {
                                thumbList.style.width = (productHeroImage.offsetHeight/4) + "px";
                                thumbList.style.minWidth = (productHeroImage.offsetHeight/4) + "px";
                                thumbList.style.height = productHeroImage.offsetHeight + "px";
                            }
                        }
                
                        window.onresize = function() {
                            if (thumbList && productHeroImage) {
                
                                for(let i=0; i < thumbFrame.length; i++) {
                                    thumbFrame[i].style.height = (productHeroImage.offsetHeight/4) + "px";
                                    thumbFrame[i].style.width = (productHeroImage.offsetHeight/4)+ "px";
                                }
                
                                if (screen.width > 720) {
                                    thumbList.style.width = (productHeroImage.offsetHeight/4) + "px";
                                    thumbList.style.minWidth = (productHeroImage.offsetHeight/4) + "px";
                                    thumbList.style.height = productHeroImage.offsetHeight + "px";
                                }
                            }
                        }
                    };
                </script>
                
                1 Reply Last reply Reply Quote 0
                • V
                  Vaishali Agarwal last edited by 18 Jan 2021, 07:46

                  @parasbhadauria63
                  please check once have you added the changes in velocity package as mention in the PR
                  check these files & changes must be added into your project as well https://prnt.sc/x3wumb

                  P 1 Reply Last reply 18 Jan 2021, 16:23 Reply Quote 0
                  • P
                    parasbhadauria63 @Vaishali Agarwal last edited by 18 Jan 2021, 16:23

                    Hi @Vaishali-Agarwal
                    I have already made the changes as mentioned above.
                    But still Buy Now is not visible in the Velocity theme.
                    Please help me out.
                    Thanks

                    1 Reply Last reply Reply Quote 0
                    • V
                      Vaishali Agarwal last edited by Vaishali Agarwal 21 Jan 2021, 10:08 21 Jan 2021, 10:07

                      Hi @parasbhadauria63
                      you need to run the publish all your asset.
                      first go to the velocity package & run command

                      npm i
                      
                      npm run watch-poll
                      

                      once these command run successfully
                      open the project root directory & run the below command
                      php artisan vendor:publish --force & press 0 to continue

                      P 1 Reply Last reply 21 Jan 2021, 10:33 Reply Quote 0
                      • P
                        parasbhadauria63 @Vaishali Agarwal last edited by 21 Jan 2021, 10:33

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • V
                          Vaishali Agarwal last edited by 21 Jan 2021, 10:46

                          @parasbhadauria63 said in How to set 'Buy now' button along with Add to card button?:

                          'npm' is not recognized as an internal or external command

                          please check npm should be installed on your system
                          refer to this for more help https://stackoverflow.com/questions/33055515/npm-is-not-recognized-as-an-internal-or-external-command-operable-program-or/33055592

                          P 1 Reply Last reply 21 Jan 2021, 12:49 Reply Quote 0
                          • P
                            parasbhadauria63 @Vaishali Agarwal last edited by parasbhadauria63 21 Jan 2021, 13:20 21 Jan 2021, 12:49

                            Hi @Vaishali-Agarwal
                            Buy Now button is visible now in the velocity theme.
                            But some of the file it could not locate (See the attached screenshot) during running the mentioned command
                            error.png

                            Due to this, I am not able to login with Google/Facebook, etc as can be seen in the other screenshot

                            Login with google erroe.png

                            1 Reply Last reply Reply Quote 0
                            • V
                              Vaishali Agarwal last edited by Vaishali Agarwal 22 Jan 2021, 03:45 22 Jan 2021, 03:44

                              @parasbhadauria63
                              Well, the error showing on the console will affect your project.
                              if you still want to fix this refer to these changes https://github.com/bagisto/bagisto/issues/4317

                              Google/facebook login integration is not related to this error, you just need to setup the app's valid client_ID or client_secret keys in .env file
                              you may also refer to this guide https://bagisto.com/en/social-login-for-bagisto/

                              I hope this will help you.
                              Thanks

                              1 Reply Last reply Reply Quote 0
                              22 out of 26
                              • First post
                                22/26
                                Last post