Skip to content

Instantly share code, notes, and snippets.

@rafhaelhp
Last active January 12, 2020 21:12
Show Gist options
  • Save rafhaelhp/7c52c35f4248cd856b8b6e5b3b889ad8 to your computer and use it in GitHub Desktop.
Save rafhaelhp/7c52c35f4248cd856b8b6e5b3b889ad8 to your computer and use it in GitHub Desktop.
Novas funções para implementação no load da aplicação
/*
* ============================================================
* Insira as funções abaixo ao final do seu arquivo '_app/Skyhub.load.php'
* ============================================================
*/
function getMlOrderStatus($status){
$StatusIds = [
'paid' => [
'name' => 'pago',
'class' => 'status_success',
],
'approved' => [
'name' => 'aprovado',
'class' => 'status_success',
],
'confirmed' => [
'name' => 'confirmado',
'class' => 'status_success',
],
'cancelled' => [
'name' => 'cancelado',
'class' => 'status_danger',
],
];
return (isset($StatusIds[$status]) ? $StatusIds[$status] : FALSE);
}
function getMlShipmentStatus($status)
{
$StatusIds = [
'to_be_agreed' => [
'name' => 'a combinar',
'class' => 'status_success',
],
'pending' => [
'name' => 'pendente',
'class' => 'status_alert',
],
'ready_to_ship' => [
'name' => 'pronto para enviar',
'class' => 'status_secondary',
],
'shipped' => [
'name' => 'enviado',
'class' => 'status_primary',
],
'delivered' => [
'name' => 'entregue',
'class' => 'status_success',
],
'not_delivered' => [
'name' => 'não entregue',
'class' => 'status_danger',
],
'cancelled' => [
'name' => 'cancelado',
'class' => 'status_danger',
],
];
return (isset($StatusIds[$status]) ? $StatusIds[$status] : FALSE);
}
/**
* Retorna a descrição da tag de atualização de um item da fila ml_update_queue
* @param $tag
* @return bool|mixed
*/
function getMlResourceLabel($resource)
{
$ResourceIds = [
"item_stock" => "Estoque",
"price" => "Preços",
"description" => "Descrição",
"title" => "Título",
];
return (isset($ResourceIds[$resource]) ? $ResourceIds[$resource] : FALSE);
}
/**
* Retorna a porcentagem sobre venda cobrado pelo ML de acordo com o tipo de publicação
* @param string $listing_type
* @return int
*/
function getMlSalePercent($listing_type) {
$ListingIds = array();
$codes = ["gold_special", "gold_pro"];
foreach ($codes as $key => $id) {
$data = cUrl::execute("https://api.mercadolibre.com/sites/MLB/listing_types/{$id}");
$ListingIds[$id] = $data['dados']['configuration']['sale_fee_criteria']['percentage_of_fee_amount'];
}
$ListingIds['free'] = 0;
return $ListingIds[$listing_type];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment