Announcement

Collapse
No announcement yet.

Get assigned categories

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    It is a typo, but it was consistent with the coupon code ... still I made it correct english

    Comment


      #32
      :deep sigh:

      I don't understand why this mvt:do call doesn't go.

      Code:
      <mvt:foreach iterator="group" array="basket:groups">
          <mvt:assign name="g.assigned_categories" value="''" />  
          <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Offset_Product_Assigned(l.settings:group:product:id,0,'','',0,l.null, g.assigned_categories )" />
          <mvt:foreach iterator="category" array="global:assigned_categories">
              <mvt:if expr="l.settings:category:code EQ 'Capstar-tablets'">
                  <mvt:do file="g.Module_Feature_PGR_RT" name="l.success" value="Action_ApplyCouponToBasket('Capstar-Special')" />
                  <p>The correct items are in the basket.</p> <---- This line will show up so the `mvt:if expr` seems to be correct but there is no evidence of a coupon code being applied.
              </mvt:if>
          </mvt:foreach>
      </mvt:foreach>
      Everything else seems to work ... it's just down to applying the coupon. Once this is working, I can replicate the needed mvt:if blocks to do what I want. It may not be the most efficient but it should work.

      But all of it is worthless unless the coupon code goes.

      edit -- 2019-05-22-1005

      I guess the last resort alternative is to put a JavaScript block in the checkout page and do the coupon check there, since I know the customer will load that page, and the client side JS will run.
      Last edited by cpp-dev; 05-22-19, 09:06 AM.

      Comment


        #33
        Could be for a number of different reasons. Few of which can be known without additional information, so, its time to play "Debug". For example:

        Code:
            <mvt:do name="l.result1" file="g.Module_Library_DB" value="CategoryList_Load_Offset_Product_Assigned(l.settings:group:product:id,0,'','',0,l.null, g.assigned_categories )" />
            <p>Debug1: <mvt:eval expr="l.result1"/></p>
        But, you also have an incorrect syntax on the foreach. When used in an expression a global variable is expressed with just "g." not "global"


        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #34
          Originally posted by Bruce - PhosphorMedia View Post
          But, you also have an incorrect syntax on the foreach. When used in an expression a global variable is expressed with just "g." not "global"
          Step 01: attempt syntax correction on line #4
          - Result: the nested loop did not output the expected paragraph text
          - Action: returned to previous var name
          - Result: the expected paragraph text is visible again
          -- Conjecture: nested loops have a different syntax?

          Step 02: add debug line after line 3
          - Result: "Debug1: 1" -- and the paragraph went away but that is expected since the variables changed.

          Comment


            #35
            Well, a nested 'loop' can have different results given what changes to the variable structure occur within the first loop, but syntax will not change. Try this:

            [code]
            <mvt:foreach iterator="group" array="basket:groups">
            <mvt:assign name="g.assigned_categories" value="''" />
            <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Offset_Product_Assigned(l .settings:group:product:id,0,'','',0,l.null, l.theseCategories)" />
            <mvt:foreach iterator="category" array="theseCategories">
            <mvt:if expr="l.settings:category:code EQ 'Capstar-tablets'">
            <mvt:do file="g.Module_Feature_PGR_RT" name="l.success" value="Action_ApplyCouponToBasket('Capstar-Special')" />
            <mvt:eval expr="'<p>Did it work: ' $l.success$ '</p>"/>
            </mvt:if>
            </mvt:foreach>
            </mvt:foreach>
            [\code]

            Bruce Golub
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment


              #36
              First thank you for your help Bruce - PhosphorMedia

              Here's the results:

              Attempted to use your suggested code:
              Code:
              <mvt:foreach iterator="group" array="basket:groups">
                <mvt:assign name="g.assigned_categories" value="''" /> 
                <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Offset_Product_Assigned(l.settings:group:product:id,0,'','',0,l.null, l.theseCategories)" />
                <mvt:foreach iterator="category" array="theseCategories">
                  <mvt:if expr="l.settings:category:code EQ 'Capstar-tablets'">
                  <mvt:do file="g.Module_Feature_PGR_RT" name="l.success" value="Action_ApplyCouponToBasket('Capstar-Special')" />
                    <mvt:eval expr="'<p>Did it work: ' $l.success$ '</p>'"/>
                  </mvt:if>
                </mvt:foreach>
              </mvt:foreach>
              Results:
              • After adding in a missing single quote the content section syntax checker was satisfied and updated the code.
              • Adding one of the products to the produced no output from the content section.

              For the sake of getting some sort of output I modified the 'known working' code with the debug message
              Code:
              <mvt:foreach iterator="group" array="basket:groups">
                  <mvt:assign name="g.assigned_categories" value="''" />  
                  <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Offset_Product_Assigned(l.settings:group:product:id,0,'','',0,l.null, g.assigned_categories )" />
                  <mvt:foreach iterator="category" array="global:assigned_categories">
                      <mvt:if expr="l.settings:category:code EQ 'Capstar-tablets'">
                          <mvt:do file="g.Module_Feature_PGR_RT" name="l.success" value="Action_ApplyCouponToBasket('Capstar-Special')" />
                          <p>The correct items are in the basket.</p>
                          <mvt:eval expr="'<p>Did it work: ' $l.success$ '</p>'"/>
                      </mvt:if>
                  </mvt:foreach>
              </mvt:foreach>
              Results:
              • The expected output was visible
              • The debug message revealed no value for "$l.success$"

              Comment


                #37

                sorry, guess someone should have checked the LSK... Action_ApplyCouponToBasket() doesn't take any parameters. The basket contents is scanned for the required inclusions/exclusions. You need (hopefully) to pass the coupon code in as a global (g.coupon_code).
                <mvt:if expr="l.settings:category:code EQ 'Capstar-tablets'"> <mvt:assign name="g.coupon_code" value="'Name_of_Coupon'"/> <mvt:do file="g.Module_Feature_PGR_RT" name="l.success" value="Action_ApplyCouponToBasket()" />
                Bruce Golub
                Phosphor Media - "Your Success is our Business"

                Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                phosphormedia.com

                Comment


                  #38
                  I'm not sure what 'LSK' stands for. But you expressed in code, what my brain was coming to re-reading the `mvt:do` docs.

                  There is some slightly unexpected behavior when I try to edit the item or have more than one of the 'correct' item in the cart, but it is operational as a proof of concept.

                  Comment


                    #39
                    Ok so looking at how the cart is now repeating itself over and over and over. Obviously the loop needs a 'stop' condition, since I want to apply the code only once per qualifying category. The most progress I've made in days.
                    Interesting second point -- The coupon is in the 'coupon' field, but the actual 'apply' action isn't done till the checkout. I'm sure this can be worked though but interesting wrinkle
                    In the BASK. clicking the 'apply' button on the coupon form triggers the 'cascade'(in Firefox), or just having the item in the BASK (when using Chrome). See the first comment about this behavior. -- https://drive.google.com/open?id=1h-...5Coh9lbMgv0bwj
                    Last edited by cpp-dev; 05-22-19, 12:50 PM.

                    Comment


                      #40
                      I've kind of lost track of the end result here...but you can have automatic 'basket' discounts based on products (so by default Categories since a categories is a set of products) using the Miva Admin settings.
                      Bruce Golub
                      Phosphor Media - "Your Success is our Business"

                      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                      phosphormedia.com

                      Comment


                        #41
                        Sorry. Bruce - PhosphorMedia -- End goal, is to have a means to automatically apply a coupon code, based on the item's category or code.

                        So now we have:
                        • the loops that go over the bask page, and get the items & their categories.
                        • a mvt "native" way to put a coupon code into the BASK page.
                        These two give us a workable base. I'm now on to refinements. I'll probably start a new thread if I need further help.

                        Thanks again Bruce - PhosphorMedia and @scot-scotscripts-com for all your guidance.

                        Comment


                          #42
                          Originally posted by cpp-dev View Post
                          Sorry. Bruce - PhosphorMedia -- End goal, is to have a means to automatically apply a coupon code, based on the item's category or code.
                          That's what it sounds like. So the question is, why not use the built in Marketing features to do this? The only difference is you'd need to select the products that are within that category individually. (You can make is somewhat easy by ensuring that products are assigned to a canonical category and sort by that segment in the "Assigned Products" list of the price group.)
                          Bruce Golub
                          Phosphor Media - "Your Success is our Business"

                          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                          phosphormedia.com

                          Comment


                            #43
                            Using the tools as you describe will give the end result, but it will not allow us to promote this feature to Google Shopping or our other advertising platforms. This seemed the best way to fulfill out contract with the manufacturer and offer our clients an easy experience.

                            The complication at the core is that the margins on the different products allow for greater an lesser discounts. Which means that there isn't a single discount that can be applied to all the items, to keep our competitive pricing and fulfill the pricing commitment made with the manufacturer. Also there isn't a way to set multiple price groups to a coupon code so even making it a single coupon was not feasible. This was the best I could come up with to work around the issue we are in.

                            Comment

                            Working...
                            X