Announcement

Collapse
No announcement yet.

Dynamically retrieving values of product variables

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

    Dynamically retrieving values of product variables

    Hi,

    I posted before about my problem with trying to integrate with affiliates:

    http://community.actinic.com/showthread.php?t=28876

    But I want to rephrase the question. I need to retrieve custom variables set at product level when I get to the receipt page. I have read the section in the advanced user guide about retrieving details of the items purchased. Unfortunately it does not mention anything about custom variables. Does anyone know how this could be be done?

    I must admit I'm a bit confused about the different types of variables in Actinic. Some have their values set depending on a page's location in the content tree and can easily be inserted on to the page. But others are set dynamically in scripts and still referred to in layouts by the same way. As well as that, there are still some NETQUOTEVAR tags around in V8. Why are these not standard variables instead? There is an ActinicOrderTotal variable but there is also NETQUOTEVAR:ACTINICORDERTOTAL which I can't understand.

    Thanks,

    James

    #2
    I need to retrieve custom variables set at product level when I get to the receipt page.
    If you check the Upload option in the variable's definition, this tells Actinic to upload that value to the web-site so that it is available to the Perl scripts. However, you have to patch the Perl scripts (usually ActinicOrder.pm to extract and do something with that value). This isn't trivial unfortunalely. Something like (from memory so may be wrong)

    $myvalue = $$pProduct{CUSTOMVARS}{MYVARIABLE};
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks for your help Norman, I did not know what that option was for. Unfortunately I don't know how to program in Perl and I'm not sure it would be worth learning such a dated language, especially as I'm more used to languages like C#. If this feature was well documented then maybe I would be able to make the changes necessary, but I can't find information about this anywhere. So I don't know where that code would go in order to access the value of a variable for a given product.

      It would really help if a developer was to explain how to read custom variables in the the scripts

      Comment


        #4
        If you haven't already have a look at this thread:
        http://community.actinic.com/showthread.php?t=28470

        Peter
        Printerbase - Colour & Mono Laser Printers

        Comment


          #5
          explain how to read custom variables in the the scripts
          Unfortunately the description of how several megabytes of Perl works is rather a lot to ask from anyone here.

          Anyway - you don't need to learn Perl to tinker with existing code. Here's the briefest demo I can think of that gets data from a Product Variable into a Cart page.

          1) Create a Product level variable WOWZA and check Upload.

          2) Edit ActinicOrder.pm (in your Site folder)
          look for the line

          Code:
          $ProdTable = ProductLineHTML($$pProduct{'REFERENCE'}, $sProdLink, $sQuantityText, $sProductLineHTML, $sDuplicateLinkLineHTML, $$pProduct{'DUPLICATES'}, $$pProduct{'THUMBNAIL'}, $bIncludeButtons);
          immediately above this add the line
          Code:
          $sProductLineHTML .= $$pProduct{CUSTOMVARS}{WOWZA};
          All we're doing here is appending the contents of WOWZA onto the product name. It's a lot more work to get it into a parameter that can be passed to the Cart or Checkout layouts.

          3) Set the value of WOWZA on some products.

          4) Update the site and add some products to the Cart and see what happens.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Hi Norman.

            Would it be simple to alter your code above for a custom variable set at CHOICE level and not at PRODUCT level? I've had a dabble with it but without too much success.

            Comment


              #7
              Hi, Dave

              Unfortunately, you cannot do this. Only variables associated with Products (and Sections) are available to the Cart scripts.

              You could perhaps embed something into the Choice name perhaps. E.g. Red(xyz17) and extract the bit in brackets.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                That's a shame. I'm currently embedding 'order code' into the choice name but was hoping for a neater solution that's easier to maintain. Not to worry. Thanks for clarifying Norm.

                Comment


                  #9
                  apologies for bumbing this thread - I find it particularly useful but it would be even more useful to me if the below was stored here - so I've added this post to store it.

                  Code:
                  my $wrtCommissionID = $$pProduct{CUSTOMVARS}{AFFILIATECOMMISSIONID};
                  $sProductLineHTML .= "<script language=\"javascript\" type=\"text/javascript\">\n<!-- \n var affiliateCommissionID = ".$wrtCommissionID.";\n // --></script>"
                  quietly scuttling off hoping no-one noticed....
                  Wayne Theisinger

                  The Web's just settling in. We got the tech, now let's put up something that matters.

                  Comment


                    #10
                    For V10 users, do post #5 above but at (2).. Look for the line, instead look for
                    Code:
                    $ProdTable = ProductLineHTML($$pProduct{'REFERENCE'}, $sProdLink, $sQuantityText, $sProductLineHTML, $sDuplicateLinkLineHTML, $$pProduct{'DUPLICATES'}, $sThumbnail, $bIncludeButtons);
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      I have tried Normans solution for our V11 site, but I was faced with a 500 server error upon uploading. Does anyone know if this should work with V11?
                      Jonathan

                      Comment


                        #12
                        Not at a V11 system at the moment so can only guess. Double-check that you've not made any typos or post the before / after code (and where you put it) so we can check here.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          Mash, tried this on a V11.0.3 system and my post #10 works OK. Must be a typo at your end.
                          Norman - www.drillpine.biz
                          Edinburgh, U K / Bitez, Turkey

                          Comment


                            #14
                            Thanks Norman.

                            I have managed to get this working in a way. It is now displaying variables in the checkout html.

                            I am trying to pass the value of some variables in to an affiliate script. So whilst this method can display the variables in the html, I am still struggling to pass the value into the script.

                            Any thoughts?
                            Jonathan

                            Comment


                              #15
                              I have tried using the following code but it generates a script error

                              my $vendor_name = $$pProduct{CUSTOMVARS}{MPN};
                              $sProductLineHTML = '<script language="javascript" type="text/javascript">' . "\r\n" .
                              var mpn = ".$vendor_name . "\r\n" .
                              '</script>' . "\r\n";

                              I was hoping to use this to create a variable mpn which I could then pass in to another piece of code.

                              If there is anyone with any experience of perl coding that could have a look at this I would greatly appreciate it.
                              Jonathan

                              Comment

                              Working...
                              X