Announcement

Collapse
No announcement yet.

Can't get custom code to work on Product Layout Page

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

    Can't get custom code to work on Product Layout Page

    We just converted out old store to Ready Themes and some of our products are Paypal restricted. We sell batons, for instance and Paypal considers that a weapon. We had written this code and it worked in the old store, but I can't get the code to show up on the Product page, even though I'm inserting it (the code below) into the Product Display Layout. We've got similar code on a checkout page that suppresses the customer from being able to pay using Paypal if the item they are purchasing is restricted. (We use a custom field to define what is restricted and what is not).
    Here is the code: Anyone got any idea why it just doesn't work?

    <!-- Start check for paypal restriction & put up warning if so --><br />
    <script type="text/javascript">
    restricted = "&mvta:product:customfield_values:customfields:res tricted;";
    if (restricted.toLowerCase() == 'PayPal'.toLowerCase()) {
    document.write('<div style="font-size:10px; color:red">'+
    '<b>IMPORTANT: This is a PayPal restricted item and cannot be paid for using PayPal. Any other available payment method is OK.</b></div>');
    }
    </script>
    <br />
    <!-- End check for paypal restriction & put up warning if so -->

    #2
    Re: Can't get custom code to work on Product Layout Page

    If you are using a custom field on the product page, make sure that field is assigned to the Product List (right below the product list template). Next, make sure that field is setup correctly and the product does indeed have that field populated. Lastly, no need to use JS to write out the notice, just use:

    <mvt:if expr="l.settings:product:customfield_values:custom fields:restricted">
    Your Restricted Product Message
    </mvt:if>
    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


      #3
      Re: Can't get custom code to work on Product Layout Page

      Now I'm really lost. I do not even see any place that says Product List Template. I'm in Edit Page: Product List. Under that is Details, Product List Layout, Product List Image Dimensions and Header and Footer.

      Here is the product list as it is now, if I'm understanding you right:
      ----
      <mvt:item name="html_profile" />
      <head>
      <title>&mvt:store:name;: &mvt:page:name;</title>
      <mvt:item name="head" param="head_tag" />
      </head>
      <mvt:item name="body">
      <mvt:item name="hdft" param="global_header" />
      <div class="row hdft-header">
      <mvt:item name="hdft" param="header" />
      </div>
      <mvt:if expr="l.settings:all_product_count GT 0">
      <mvt:item name="all_products" />
      </mvt:if>
      <div class="row hdft-footer">
      <mvt:item name="hdft" param="footer" />
      </div>
      <mvt:item name="hdft" param="global_footer" />
      </mvt:item>


      </html>
      ----

      I don't really know miva coding so I don't know what to put in here to make it work, or if this is even where you mean to put the info.

      Comment


        #4
        Re: Can't get custom code to work on Product Layout Page

        You want to be on the PROD page template, then look for the Product Display Layout. Just below that, you'll see Custom Fields with two boxes. You need to use the select the ones in the left hand box, then click the Select button to move them to the right side box.

        If you haven't already, you need to then click the "Advanced Mode" link towards the bottom of the Product Display Layout area. Once you do that, you'll see the Product Display Layout template code. You'd insert the code

        <mvt:if expr="l.settings:product:customfield_values:custom fields:restricted">
        Your Restricted Product Message
        </mvt:if>

        Where you want the message to appear.

        NOTE: I'm assuming here that the custom product field is still configured with the field code of 'restricted'
        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


          #5
          Re: Can't get custom code to work on Product Layout Page

          Bruce,
          Thank you for explaining it for me. I was able to get it to work. But there is another issue with 2 pieces of other code that was written for the old site's checkout pages, which didn't allow Paypal as a payment method if the product/products were in the custom field called restricted. It's great that now restricted items like batons now have a warning on the product page, but I need to prevent those items to be able to be paid for using paypal.
          Like I said, I have the 2 pieces of code that was written for the old site, which I could add here if you'd like, but maybe you know of an easier way for me to accomplish this. I tried to paste in the code on the same pages from the old site to the new, but they just don't do anything.
          In the nutshell, I just need to prevent a customer whi is purchasing a restricted item from using Paypal as a method of Payment.
          Thanks again for all your help.
          Mike

          Comment


            #6
            Re: Can't get custom code to work on Product Layout Page

            You'd have to run similar code in the Basket Contents template to detect a "prohibited" product (this would go after the " <mvt:foreach iterator="item" array="basket:items">" item

            <mvt:if expr="l.settings:item:customfield_values:customfie lds:retricted;" >
            <mvt:assign name="g.hasRestrictedProduct" value="'yes'">
            </mvt:if>

            Then, in your Payment Options list on OSEL, you need to add

            <mvt:foreach array="paymentmethods" iterator="method">

            <mvt:if expr="l.settings:paymentmethods:module EQ 'paypal' AND g.hasRestritedProuct">
            <mvt:else>
            <li><input type="radio" name="PaymentMethod" value="&mvte:method:module;:&mvte:method:code;" />&nbsp;&nbsp;&mvt:method:name;</li>
            </mvt:if>

            </mvt:foreach>

            (Note, from memory, actual values may be different)
            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

            Working...
            X