Jump to content

Help needed.


Vixushr

Recommended Posts

Helo dear people,

 

I need some halp with mine script.

 

This is part of it that works:

 

function msan_getxmlinfo() {

    //global $local;

    //msan_download();

 

    $path = dirname(__FILE__).'/xml/pricelist.xml';

    $doc = new DOMDocument();

    $doc->load($path);

    $msan = $doc->getElementsByTagName( "Table" );

    $result = array();

    foreach( $msan as $table ) {

        $codes = $table->getElementsByTagName( "ProductCode" );

        $code = $codes->item(0)->nodeValue;

        $prices = $table->getElementsByTagName( "ProductPartnerPrice" );

        $price = $prices->item(0)->nodeValue;

        $price = sprintf('%6f',$price);

        $availables = $table->getElementsByTagName( "ProductAvailability" );

        $available = $availables->item(0)->nodeValue;

        $result[$code] = array('code'=>$code,'price'=>$price,'available'=>$available);

    }

    //echo "<pre>";

    //print_r($result);

    //@unlink($path);

 

    return $result;

}

 

But now i need to insert one more element called "ProductDiscount"

 

And aditional condition for proper price setting related so that when "ProductDiscount" is 0 (zero) then increase price by 3% and if theres any other value than 0 (zero) leave price as is.

 

I was trying somthing like this but i cant get price increase:

 

function msan_getxmlinfo() {

 

    $path = dirname(__FILE__).'/xml/pricelist.xml';

    $doc = new DOMDocument();

    $doc->load($path);

    $msan = $doc->getElementsByTagName( "Table" );

    $result = array();

    foreach( $msan as $table ) {

        $codes = $table->getElementsByTagName( "ProductCode" );

        $code = $codes->item(0)->nodeValue;

        $prices = $table->getElementsByTagName( "ProductPartnerPrice" );

        $price = $prices->item(0)->nodeValue;

        $discounts = $table->getElementsByTagName( "ProductDiscount");

if($discounts->item(0)=="0") {

    $price = $price*1.03;

}

else {

    $price = $prices->item(0)->nodeValue;

}

$price = sprintf('%6f',$price);

        $availables = $table->getElementsByTagName( "ProductAvailability" );

        $available = $availables->item(0)->nodeValue;

        $result[$code] = array('code'=>$code,'price'=>$price,'available'=>$available,'discount'=>$discount);

    }

    return $result;

}

 

Help needed!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.