Bagisto Forum

    Bagisto

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

    how to change product-card__badge

    General Discussion
    3
    14
    896
    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.
    • R
      rahul last edited by

      Hello,

      When any cart rule gets applied on the product after adding it to cart then you can get its percentage using 'discount_percent' column in 'cart_items' table.

      Thanks

      1 Reply Last reply Reply Quote 0
      • G
        gayanpriyankara last edited by

        i want it to show on the product badge

        1 Reply Last reply Reply Quote 0
        • R
          rahul last edited by

          Hello @gayanpriyankara

          You can not apply cart rule until the product is not added in the cart but according to your requirement, you can create a catalogue rule for the same ( It is also part of promotion ).

          It is applied to the product without any delay and from haveSpecialPrice method of product type, you can get which rule is applied and can show their desired values.

          1 Reply Last reply Reply Quote 0
          • G
            gayanpriyankara last edited by

            @rahul
            am sorry my mistake i have asked the question ina wrong way
            this is the real problem

            I was trying to show the cart rule percentage or the name on the product badge so that the coustomer can see the given promotion to the product but I couldn't

            1 Reply Last reply Reply Quote 0
            • R
              rahul last edited by

              Hi @gayanpriyankara

              You can get the applied cart rule from 'applied_cart_rule_ids' in the cart and cart_items table and can show the desired data (like name, percentage or price for discount) on product badge.

              G 1 Reply Last reply Reply Quote 0
              • G
                gayanpriyankara last edited by

                @rahul
                can you please assist me hot show the percentage of the discount in the product badge
                as shown in the image i want to show the percentage of the discount instead of "new"
                img1.JPG

                1 Reply Last reply Reply Quote 0
                • V
                  vishalK last edited by

                  Hi @gayanpriyankara

                  To show percentage of discount inside badge first you have to do some customisation.

                  1. First open the folder which is given below:
                    $root_folder/packages/Webkul/Product/src/Type
                  2. Inside this folder you will find all product type file (7 files like downloadable, virtual, etc..)
                  3. open each file and find getPriceHtml() function.
                  4. Now inside this getPriceHtml() function you will find sale sticker tag like image given below:ea58c254-4b46-47e8-89a2-48760fbc6e6d-image.png
                  5. Now inside this function first you have to calculate discount percentage using special price and add that percentage inside sticker sale div.

                  Now whenever you set special price of product your logic inside getPriceHtml() function calculate discount percentage using special price and set that percentage inside sticker sale div so in front-end you will see discount percentage inside badge.

                  Note: Kindly take backup of project before performing above steps.

                  Thanks

                  1 Reply Last reply Reply Quote 0
                  • G
                    gayanpriyankara last edited by

                    @vishalK thank you very much for the help
                    but what i need is i want to show the percentage discount when we apply a promotion in cart-rule
                    the discount amount (20%)

                    1 Reply Last reply Reply Quote 0
                    • R
                      rahul last edited by

                      Hi @gayanpriyankara

                      Open the AbstractType.php file inside the Product package and replace the below code in getPriceHtml() method.

                      if ($this->haveSpecialPrice()) {
                                  $per = (($this->product->price - $this->getSpecialPrice()) * 100)/$this->product->price;
                                  
                                  $html = '<div class="sticker sale">' . $per .'%'. '</div>'
                                      . '<span class="regular-price">' . core()->currency($this->product->price) . '</span>'
                                      . '<span class="special-price">' . core()->currency($this->getSpecialPrice()) . '</span>';
                              } else {
                                  $html = '<span>' . core()->currency($this->product->price) . '</span>';
                              }
                      
                              return $html;
                      

                      Thanks
                      Rahul Shukla

                      1 Reply Last reply Reply Quote 0
                      • G
                        gayanpriyankara last edited by

                        @rahul thank a lot bro it helped to get the % to the sale items

                        1 Reply Last reply Reply Quote 0
                        • G
                          gayanpriyankara @rahul last edited by

                          @rahul hi can you show me how to do this too

                          1 Reply Last reply Reply Quote 0
                          • R
                            rahul last edited by

                            Hi @gayanpriyankara

                            I don't get what are you asking, please explain more.

                            Thanks

                            1 Reply Last reply Reply Quote 0
                            • G
                              gayanpriyankara last edited by gayanpriyankara

                              @rahul
                              ok lets say ,
                              we are giving a discount (20%) to a certain Category so when we search for a product in the web the sticker should be 20% like "new" so the customer will know that this product has 20 discount if he buy it
                              if we can get the cart-rule name or the percentage of the discount to the sticker that will be great

                              thanks in advance

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post