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
https://forums.phpfreaks.com/topic/230079-help-needed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.