Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default php coding help please..

    Hi guys,

    I have a problem i'm trying to solve but hitting a brick wall at the moment, I'm sure its probably very simple for someone that has the background knowledge..

    Basically, I have a script that is pulling all the relevant details from my orders to put into an xml generator script.

    For it to work for me, I need to manipulate my product codes based on option values selected by the customer, however, some products have dropdown attributes which get passed into the orders_products_attributes table but products with text only attributes do not populate this table.

    Hereth comes my problem,

    For products with the selectable attributes the following would have to happen:
    if small (model 1000) is selected
    I need it to be 1000S
    if a medium (model 1000) is selected
    I need it to be 1000M
    if a model with text attribute is selected (model 1001)
    I need it to stay 1001

    So my loop basically finds the ordered products and finds in the orders_products_attributes the associated options value id (if it exists) to echo the result. from this I then use the result to minipulate the code with the following:

    PHP Code:
    if ($ordersproductsattributes == '4')
    {
    $fullprodid $prodmod."S";
    }
    elseif (
    $ordersproductsattributes == 5)
    {
    $fullprodid $prodmod."M";
    }
    elseif (
    $ordersproductsattributes == 6)
    {
    $fullprodid $prodmod."L";
    }
    else
    $fullprodid $prodmod;


    echo 
    "FULL CODE: $fullprodid"
    Break down:
    $ordersproductsattributes is the option value id
    $prodmod is the product model
    $fullprodid is the full output I want

    I thought that the last line I have here would do what I needed it to do, is in:

    else
    $fullprodid = $prodmod;

    so if none of the above apply, $fullprodid will equal the product model. However it would seem that because there is no value for the text attributes in the orders_products_attributes table, its missing these out.

    Its almost like I need something to say,

    if this ordered product has an option value id in orders_products_attributes table then do this, otherwise do this instead???

    That probably makes no sense but i'm hoping it will to someone. I'm sure its probably something very basic that would fix it too, but i'm in over my head

    Any Help would be much appreciated.

    Cheers
    Phil

  2. #2
    Join Date
    Jun 2008
    Location
    Washington, DC
    Posts
    789
    Plugin Contributions
    7

    Default Re: php coding help please..

    There is a 1000 ways to this. Maybe this simple example will help you.
    PHP Code:
    <?php
    // model_id
    $prodmod '1000';

    // orders products attributes
    $ordersproductsattributes 9// change to 4, 5 or 6 to see if work

    if (($ordersproductsattributes 0) && ($ordersproductsattributes 8)) {

        if (
    $ordersproductsattributes == 4){
            
    $fullprodid $prodmod.'S';
        }
        if (
    $ordersproductsattributes == 5){
            
    $fullprodid $prodmod.'M';
        }
        if (
    $ordersproductsattributes == 6){
            
    $fullprodid $prodmod.'L';
        }
       echo 
    'FULL CODE: '$fullprodid;
    } else {
       echo 
    'JUST MODEL CODE: '$prodmod;
    }
    ?>
    Skip
    • 446F63746F722057686F •

  3. #3
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: php coding help please..

    Quote Originally Posted by skipwater View Post
    There is a 1000 ways to this. Maybe this simple example will help you.
    PHP Code:
    <?php
    // model_id
    $prodmod '1000';

    // orders products attributes
    $ordersproductsattributes 9// change to 4, 5 or 6 to see if work

    if (($ordersproductsattributes 0) && ($ordersproductsattributes 8)) {

        if (
    $ordersproductsattributes == 4){
            
    $fullprodid $prodmod.'S';
        }
        if (
    $ordersproductsattributes == 5){
            
    $fullprodid $prodmod.'M';
        }
        if (
    $ordersproductsattributes == 6){
            
    $fullprodid $prodmod.'L';
        }
       echo 
    'FULL CODE: '$fullprodid;
    } else {
       echo 
    'JUST MODEL CODE: '$prodmod;
    }
    ?>
    Skip
    Thanks for you suggestion skipwater. I used the if instead of elseif but also turns out all I needed to do was set $fullprodid = $prodmod before the while loop so that when there was nothing to return in the loop it took the original value.

    Cheers

 

 

Similar Threads

  1. v139h Sidebox coding problems...... please help
    By kitten091182 in forum General Questions
    Replies: 6
    Last Post: 16 Feb 2015, 11:58 AM
  2. v150 Need help with module php coding please. Short and Sweet
    By VBE-1 in forum General Questions
    Replies: 2
    Last Post: 2 Oct 2012, 01:29 AM
  3. Some coding help please
    By malc in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 8 Jun 2011, 08:17 AM
  4. Coding help please
    By Nixak in forum General Questions
    Replies: 0
    Last Post: 24 Jul 2009, 03:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg