Announcement

Collapse
No announcement yet.

Toolkit Favorites List (custadd / custdelete)

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

    Toolkit Favorites List (custadd / custdelete)

    I've successfully created a "My Favorites" list using Toolkit and have modified PROD/ACLN accordingly to get it to work how I want with one exception. Based on how Toolkit adds items to the custom customer field, my product page snippet isn't updating as I'd like. The site is still offline in preparation for launch so I can't show the actual page but below is the code and a quick explanation of what it does and what I'd like it to do...

    Code:
    <mvt:if expr="g.basket:cust_id GT 0">
        <mvt:item name="customfields" param="Read_Customer_ID( g.basket:cust_id, 'myfavs', l.settings:customfields )" />
        <mvt:if expr = " l.settings:product:code IN l.settings:customfields ">
            <i class="icon-plus-sign-alt"></i> Add to MyFavorites &nbsp;&nbsp; | &nbsp;&nbsp;
            <i class="icon-minus-sign-alt"></i> <a href="&mvte:global:sessionurl;Screen=PROD&Product_Code=&mvta:global:Product_Code&Category_Code=&mvta:global:Category_Code;&Store_Code=&mvta:global:store_code;&favdelete=&mvta:global:Product_Code;">Remove from MyFavorites</a> &nbsp;&nbsp; | &nbsp;&nbsp;
            <mvt:if expr="g.favdelete">
                <mvt:item name="toolkit" param="custdelete|myfavs|g.favdelete" />
            </mvt:if>
        <mvt:else>
            <i class="icon-plus-sign-alt"></i> <a href="&mvte:global:sessionurl;Screen=PROD&Product_Code=&mvta:global:Product_Code;&Category_Code=&mvta:global:Category_Code;&Store_Code=&mvta:global:store:code;&favorite=&mvta:global:Product_Code;">Add to MyFavorites</a> &nbsp;&nbsp; | &nbsp;&nbsp;
            <mvt:if expr="g.favorite">
                <mvt:item name="toolkit" param="custadd|myfavs|g.favorite" />
            </mvt:if>
            <i class="icon-minus-sign-alt"></i> Remove from MyFavorites &nbsp;&nbsp; | &nbsp;&nbsp;
        </mvt:if>
        <i class="icon-list-alt"></i> <mvt:item name="cssui_links" param="customer_account">View/Manage MyFavorites</mvt:item>
    </mvt:if>
    So here's what happens... When the product page loads it checks for a logged in customer. If there is one it displays the Toolkit functions for the Favorites List. It also checks the customers current Favorites List in order to display the relevant links. For example, if the current product is in the customers list it will display the remove link while deactivating the add link. Likewise, if it's not in the list, it will then display the add link while deactivating the remove link.

    This all functions fine for the actual Favorites List but I'm running into trouble having the product page accurately reflect the addition or removal of the item. When clicking either link, the page refreshes and Toolkit performs the function of adding/removing it on the list. However, the link is still active because the logic checking for the item on the list executes before the Toolkit function. A second click on the link or additional page refresh is necessary in order for it to update the links accordingly, deactivating one link and activating the other.

    I've tried a number of things without success and the adding/removing works fine while keeping the customer on the product page. It's now just a matter of getting those fields to update accordingly when the page refreshes for the Toolkit function. I didn't want to bother Bill with a support ticket as the functions are working so hopefully someone has an idea or solution for the page updating that I overlooked.

    Any help you can offer is greatly appreciated.

    Thanks,
    Tim

    #2
    Re: Toolkit Favorites List (custadd / custdelete)

    You can move the toolkit code up above the header or between header and body on the page and have it set global variables you can then test for to show the stuff you need further down in the page. That **should** get the toolkit stuff done before anything else. We use this same tactic on checkout pages a bunch.

    Comment


      #3
      Re: Toolkit Favorites List (custadd / custdelete)

      Originally posted by nottheusual1 View Post
      You can move the toolkit code up above the header or between header and body on the page and have it set global variables you can then test for to show the stuff you need further down in the page. That **should** get the toolkit stuff done before anything else. We use this same tactic on checkout pages a bunch.
      I suddenly feel really stupid :)

      I think I spent way too much time looking at it and making it more complicated than it was. Simply moving both of the Toolkit expressions as you suggested did the trick. They only needed to go above the Custom Fields expression allowing them to execute right before checking for the value.

      In case anyone finds themselves in the same boat, here's the modified code...

      Code:
      <mvt:if expr="g.basket:cust_id GT 0">
          <mvt:if expr="g.favdelete">
              <mvt:item name="toolkit" param="custdelete|myfavs|g.favdelete" />
          </mvt:if>
          <mvt:if expr="g.favorite">
              <mvt:item name="toolkit" param="custadd|myfavs|g.favorite" />
          </mvt:if>
          <mvt:item name="customfields" param="Read_Customer_ID( g.basket:cust_id, 'myfavs', l.settings:customfields )" />
              <mvt:if expr = " l.settings:product:code IN l.settings:customfields ">
                  <i class="icon-plus-sign-alt"></i> Add to MyFavorites &nbsp;&nbsp; | &nbsp;&nbsp;
                  <i class="icon-minus-sign-alt"></i> <a href="&mvte:global:sessionurl;Screen=PROD&Product_Code=&mvta:global:Product_Code&Category_Code=&mvta:global:Category_Code;&Store_Code=&mvta:global:store_code;&favdelete=&mvta:global:Product_Code;">Remove from MyFavorites</a> &nbsp;&nbsp; | &nbsp;&nbsp;
              <mvt:else>
                  <i class="icon-plus-sign-alt"></i> <a href="&mvte:global:sessionurl;Screen=PROD&Product_Code=&mvta:global:Product_Code;&Category_Code=&mvta:global:Category_Code;&Store_Code=&mvta:global:store:code;&favorite=&mvta:global:Product_Code;">Add to MyFavorites</a> &nbsp;&nbsp; | &nbsp;&nbsp;
                  <i class="icon-minus-sign-alt"></i> Remove from MyFavorites &nbsp;&nbsp; | &nbsp;&nbsp;
              </mvt:if>
          <i class="icon-list-alt"></i> <mvt:item name="cssui_links" param="customer_account">View/Manage MyFavorites</mvt:item>
      </mvt:if>
      Thanks for setting me straight nottheusual1.

      Tim

      Comment


        #4
        Re: Toolkit Favorites List (custadd / custdelete)

        Even blind nuts can trip over a squirrel on occasion -- glad to help. :)
        Last edited by nottheusual1; 01-29-14, 02:56 PM.

        Comment

        Working...
        X