Post by feedermania » Fri Feb 21, 2020 11:35 pm

Hello guys. im very beginner. I have a discount value on my customer table (for all products).
I want to add the discount line to an XML link.
I tried a lot, but i dont know what im doing.. :)
if($item == 'discount'){$xml .= ''.htmlspecialchars($order['discount']).''."\n";}
Example: 31.03 (this value is percentage discount)

I want this line to the corn link:
HERE IS THE LINE: Image

HERE IS THE CODE-.

Code: Select all

<?php 
class ModelExtensionModuleXMLExportOrder extends Model {


	public function XMLFolder(){
    return DIR_SYSTEM.'../xml/';
	}
	public function XMLFile(){
    return DIR_SYSTEM.'../xml/xml_export_order.xml';
	}

	public function exportOrders($export_items) {

	  $xml = '';
	  $xml .= '<'.'?xml version="1.0" encoding="UTF-8"'.'?'.'>'."\n";
	  $xml .= '<ORDERS>'."\n";
		$xml .= '<DATE_CREATED>'.date("Y-m-d H:i",time()).'</DATE_CREATED>'."\n";
	
	
    $filter = $export_items['filter'];
    
    $price_with_code = false;
    /*
    if(isset($filter['currency_code']) AND $filter['currency_code'] == 1){
      $price_with_code = true;
    }
    */
    
    if(isset($filter['order_status']) AND $filter['order_status'] != "-"){
      $filter_sql[] = "order_status_id = '".(int)$filter['order_status']."'";
    }
    
    if(isset($filter['order_date_start']) || isset($filter['order_date_stop'])){
      if(isset($filter['order_date_start']) AND $filter['order_date_start'] != ""){
        $filter_sql[] = "date_added >= '".$filter['order_date_start']." 00:00:00'";
      }
      if(isset($filter['order_date_stop']) AND $filter['order_date_stop'] != ""){
        $filter_sql[] = "date_added <= '".$filter['order_date_stop']." 23:59:59'";
      }
    }
    if(isset($filter['order_store']) AND $filter['order_store'] != "-"){
      $filter_sql[] = "store_id = '".(int)$filter['order_store']."'";
    }
    
    $export_items['xml_export_order_items'][] = 'products';


    $sql = "SELECT * FROM `" . DB_PREFIX . "order` WHERE 1 = 1";
    
    if(isset($filter_sql)){
      $sql .= " AND ".implode(" AND ",$filter_sql);
    }
		$query = $this->db->query($sql);
    
		if($query->rows){
    foreach($query->rows as $order){
    
	  $xml .= '<ORDER>'."\n";
    
   if(isset($export_items['xml_export_order_items'])){
    foreach($export_items['xml_export_order_items'] as $item){
      if($item == 'order_id'){
        $xml .= '<ORDER_ID>'.htmlspecialchars($order['order_id']).'</ORDER_ID>'."\n";
        
      }
      /*HERE IS THE LINE*/
      if($item == 'discount'){$xml .= '<CUSTOMER_DISCOUNT>'.htmlspecialchars($order['discount']).'</CUSTOMER_DISCOUNT>'."\n";}

New member

Posts

Joined
Mon Jul 30, 2018 2:48 am

Post by xxvirusxx » Sat Feb 22, 2020 12:29 am

Duplicate
viewtopic.php?f=198&t=216207

If you didn't get a free answer then you can try on Commercial section.
viewforum.php?f=88

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by feedermania » Sat Feb 22, 2020 2:01 am

the first one is closed

New member

Posts

Joined
Mon Jul 30, 2018 2:48 am

Post by xxvirusxx » Sat Feb 22, 2020 5:37 am

Then you can edit topic title and add [SOLV ED] before.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Sat Feb 22, 2020 11:59 am

I don't see this topic: viewtopic.php?f=198&t=216207 as being closed ... people can still reply on that topic.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Sat Feb 22, 2020 12:38 pm

Code: Select all

$export_items['xml_export_order_items'][] = 'products';

foreach($export_items['xml_export_order_items'] as $item){
	
	if($item == 'order_id') {........}
	if($item == 'discount') {........}


Now why do you think these two if statement won't fire.
Why query the order table when the discount value is in the customer table?
I tried a lot, but i dont know what im doing..
True.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by feedermania » Sun Feb 23, 2020 3:53 am

okay i see. and how to query the customer table too with the order table? i want only the discount value from customer table :S

New member

Posts

Joined
Mon Jul 30, 2018 2:48 am

Post by straightlight » Sun Feb 23, 2020 7:00 am

feedermania wrote:
Sun Feb 23, 2020 3:53 am
okay i see. and how to query the customer table too with the order table? i want only the discount value from customer table :S
Double post: viewtopic.php?f=199&t=216237#p777941

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 9 guests