create order status new in prestashop
public function createOrderState()
{
if (!Configuration::get('CUSTOM_OS_ERROR')) {
$order_state = new OrderState();
$order_state->name = [];
foreach (Language::getLanguages() as $language) {
$order_state->name[$language['id_lang']] = 'Custom Error State';
}
$order_state->send_email = false;
$order_state->invoice = true;
$order_state->color = '#ff4434';
$order_state->logable = true;
$order_state->delivery = false;
$order_state->hidden = false;
$order_state->shipped = false;
$order_state->paid = true;
if ($order_state->add()) {
$source = _PS_ROOT_DIR_.'/img/os/'.Configuration::get('PS_OS_ERROR').'.gif';
$destination = _PS_ROOT_DIR_.'/img/os/'.(int)$order_state->id.'.gif';
copy($source, $destination);
}
Configuration::updateValue('CUSTOM_OS_ERROR', (int)$order_state->id);
}
}
{
if (!Configuration::get('CUSTOM_OS_ERROR')) {
$order_state = new OrderState();
$order_state->name = [];
foreach (Language::getLanguages() as $language) {
$order_state->name[$language['id_lang']] = 'Custom Error State';
}
$order_state->send_email = false;
$order_state->invoice = true;
$order_state->color = '#ff4434';
$order_state->logable = true;
$order_state->delivery = false;
$order_state->hidden = false;
$order_state->shipped = false;
$order_state->paid = true;
if ($order_state->add()) {
$source = _PS_ROOT_DIR_.'/img/os/'.Configuration::get('PS_OS_ERROR').'.gif';
$destination = _PS_ROOT_DIR_.'/img/os/'.(int)$order_state->id.'.gif';
copy($source, $destination);
}
Configuration::updateValue('CUSTOM_OS_ERROR', (int)$order_state->id);
}
}
Comments
Post a Comment