Opencart + koppeling WMS vraagje

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Bas Niet belangrijk

Bas Niet belangrijk

17/09/2017 13:48:37
Quote Anchor link
Beste PHP'ers,

Ik heb een OpenCart webwinkel + template + Ideal-checkout (pluggin) ge"installeerd.

De voorraad zal extern opgeslagen worden. Deze partij zal ook de orders picken, versturen, retour afhandelen etc. Deze partij werkt met een warehouse management systeem welke remote te benaderen is via XML.

Nu heb ik zelf heel weinig ervaring met OpenCart en de achterliggende structuur van het systeem.
Ik weet dan ook niet zo goed op welke pagina / controller de laatste handeling in het verwerkproces afgehandeld word. Ik heb de product ID's, aantallen, adres, telefoonnummer omtrent de bestelling nodig zodat ik deze in het WMS kan schieten.

Kan iemand mij op weg helpen ?

Groeten,
Bas
 
PHP hulp

PHP hulp

26/04/2024 19:29:56
 
Ward van der Put
Moderator

Ward van der Put

17/09/2017 14:35:31
Quote Anchor link
Lijkt me meer een vraag voor het OpenCart-forum:

https://forum.opencart.com/viewtopic.php?t=187244

Weet je welke software het WMS gebruikt?
 
Bas Niet belangrijk

Bas Niet belangrijk

17/09/2017 15:28:46
Quote Anchor link
Hoi Ward,

Daar heb ik tweemaal een topic geopend, hier kwamen echter geen reacties op.

Het gaat om een oplossing van 3BM. De volgende code hebben zij aangeleverd.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
// start xml string soap
// opbouwen van de XML string op basis van de order die naar warehouse moet

$xmlstring = '';
$xmlstring .= '<?xml version="1.0" encoding="UTF-8"?>';
$xmlstring .= '<orders>';
$i= "0";

try
{
// get list of orders
// ophalen order(s)

$completed_orders = salesOrderList();
}

catch (Exception $e)
{

$l_error_mess = $e -> getMessage ();
exit;
}

$l_i = 0;
foreach ( $completed_orders as $order_header )
{

$l_i = $l_i + 1;
// get order data and place in variables
$order_increment_id = ($order_header->increment_id);
$i=(1);
$order_id = ($order->increment_id);
$order_store = ($order->store_name);
$order_order_number = ($order->order_id);
$order_created_at = ($order->created_at);
$order_updated_at = ($order->updated_at);
// enzovoorts
//
//opbouwen xml string op basis van variabelen

$xmlstring .= '<order>';
$xmlstring .= '<orderid>' . $order_id . '</orderid>';
$xmlstring .= '<shop>' . $order_store . '</shop>';
$xmlstring .= '<customerid>' . '</customerid>';
$xmlstring .= '<email>' . $order_customer_email . '</email>';
$xmlstring .= '<phone>' . $order_billing_address_phone . '</phone>';
$xmlstring .= '<language>' . 'NL' . '</language>';
$xmlstring .= '<billing>';
$xmlstring .= '<billing_company>' . '</billing_company>';
$xmlstring .= '<billing_first_name>' . $order_billing_address_first_name .
'</billing_first_name>';
$xmlstring .= '<billing_last_name>' . $order_billing_address_last_name .
'</billing_last_name>';
$xmlstring .= '<billing_address>' . $order_billing_address_address_1 .
'</billing_address>';
$xmlstring .= '<billing_postal>' . $order_billing_address_postcode .
'</billing_postal>';
$xmlstring .= '<billing_city>' . $order_billing_address_city . '</billing_city>';
$xmlstring .= '<billing_country>' . $order_billing_address_country .
'</billing_country>';
$xmlstring .= '</billing>';
$xmlstring .= '<shipping>';
$xmlstring .= '<shipping_method>' . $order_shipping_methods . '</shipping_method>';
$xmlstring .= '<shipping_company>' . '</shipping_company>';
$xmlstring .= '<shipping_first_name>' . $order_shipping_address_first_name .
'</shipping_first_name>';
$xmlstring .= '<shipping_last_name>' . $order_shipping_address_last_name .
'</shipping_last_name>';
$xmlstring .= '<shipping_address>' . $order_shipping_address_address_1 .
'</shipping_address>';
$xmlstring .= '<shipping_postal>' . $order_shipping_address_postcode .

'</shipping_postal>';
$xmlstring .= '<shipping_city>' . $order_shipping_address_city . '</shipping_city>';
$xmlstring .= '<shipping_country>' . $order_shipping_address_country .
'</shipping_country>';

$xmlstring .= '</shipping>';
$xmlstring .= '<invoice>';
$xmlstring .= '<incoterm>20</incoterm>';
$xmlstring .= '<shipping_currency>' . $order_currency . '</shipping_currency>';
$xmlstring .= '<shipping_cost>' . '</shipping_cost>';
$xmlstring .= '<total_order_currency>' . $order_currency . '</total_order_currency>';
$xmlstring .= '<total_order_value>' . $order_total . '</total_order_value>';
$xmlstring .= '<show_price>' . 'N' . '</show_price>';
$xmlstring .= '<order_description>' . '' . '</order_description>';
$xmlstring .= '</invoice>';
$xmlstring .= '<items>';

// get order lines
$orderItems = $order->items;
foreach($orderItems as $orderItem)
{

$order_line_items_id = ($orderItem->item_id);
$order_line_items_total = ($orderItem->row_total);
$order_line_items_total_tax = ($orderItem->tax_amount);
$order_line_items_price = ($orderItem->price);
$order_line_items_quantity = ($orderItem->qty_ordered);
$order_line_items_name = ($orderItem->name);
$order_line_items_product_id = ($orderItem->product_id);
$order_line_items_sku = ($orderItem->sku);

// build item xml
$xmlstring .= '<item>';
$xmlstring .= '<ProductName>' . $order_line_items_name . '</ProductName>';
$xmlstring .= '<ProductCode>' . $order_line_items_product_id . '</ProductCode>';
$xmlstring .= '<quantity>' . $order_line_items_quantity . '</quantity>';
$xmlstring .= '<item_units>' . '1' . '</item_units>';
$xmlstring .= '<item_price>' . $order_line_items_total . '</item_price>';
$xmlstring .= '<item_weight>' . '</item_weight>';
$xmlstring .= '</item>';
}

// close item xml
$xmlstring .= '</items>';
$xmlstring .= '</order>';
$xmlstring = str_replace("\r", "", $xmlstring);
$xmlstring = str_replace("\n", "", $xmlstring);
}

if ($i == "0")
{

$v_error_mess = "Message: " . "Er staan geen orders klaar om te exporteren" ;
exit;
}

$xmlstring .= '</orders>';

// prepare soap connection
$options = array
( 'trace' => 1, // enable trace to view what is happening
'exceptions' => 1, // disable exceptions
'cache_wsdl' => 0, // disable any caching on the wsdl, encase you alter the
wsdl server
// login naam om soap te benaderen (via 3BM)
'loginname'=>SHOP_LOGINNAME,
'password'=>SHOP_PASSWORD,
);


try
{
$client_s = new SoapClient(SOAP_URL, $options);
$xmlstring_soap = array
( 'loginname' => SHOP_LOGINNAME,
'password' => SHOP_PASSWORD,
'version' => SHOP_VERSION,
'xml' => $xmlstring,
);


// call soap function
$response = $client_s->order_creation($xmlstring_soap);

}

catch (Exception $e)
{

$l_error_mess = $e -> getMessage ();
$v_error_mess = "Error " . $l_error_mess . " Last response: " . $client_s-
>
__getLastResponse();
driebm_log($v_error_mess);
exit;
}

// process return file soap call
//xml strippen van omliggende tags

$simple = ($client_s->__getLastResponse());
$simple_s = ( explode( '?&gt;', $simple ) );
$simple_e = ( explode( '</order_creationResult>', $simple_s[1] ) );

$xmlObject_str = htmlspecialchars_decode($simple_e[0]);

// omzetten XML naar Array om elementen te benaderen
$xmlObject = new SimpleXMLElement($xmlObject_str);

foreach ($xmlObject->order as $result)
{

$result_orderid = $result->orderid;
$result_status = $result->status;
$result_error = $result->error;
$result_error_line = $result->error->line;
$result_date_time = $result->date_time;
if ($result_status == "error")
{

echo "<br>naar error " . $result_orderid . " | " . $result_error_line;
}

if ($result_status == "pending")
{

$c_order_status = 'processing';
// update your order with new status
// $result = update_order();
//

echo "<br>naar completed " . $result_orderid;
}
}
}

?>
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.