OPENCART APP -> Customer Orders not being bound to Customer - php

Customer Orders not being bound to Customer
Postby DrFeeling » Mon Jun 01, 2015 4:05 pm
Good Afternoon peeps, I'm currently developping a mobile app for opencart that will bridge both tecnologies.
Most of the stuff is already active but I have a problem regarding order histories.
So, when you purchase something, through the main site, the default template of opencart, it generates a order history, that you can see through the website (my orders) or through the admin page.
My problem is that, whenever someone purchases something from the app, the orders of that costumer arent uptaded.
Though they appear in the main admin window (the dashboard) , once you go to customer (sales -> customers -> customers) the order made by the app isnt listed in the myOrders part of that customer, making both the "my previous orders" and the order of that customer inexistent in that place, but they appear in the dashboard and the notification email is foward to the customer
Please help me, and thanks for the support :D
Only order 261 (which was made in the website) is bounded to its customer, the others arent, as you can see in the pic below
AM I missing a parameter or a validation when the checkout process happens?
http://s16.postimg.org/y2h9rg5fp/image.jpg
EDIT: My code to create a order:
public function end_order() {
if ($this->customer->isLogged() == true){
$data= array();
$datap = array();
$this->load->model('account/customer');
$this->load->model('quickcheckout/order');
$this->load->model('checkout/order');
$myArray = $_POST["formData"];
$treatedArray = array();
foreach($myArray as $value) {
$treatedArray[$value['name']] = $value['value'];
}
$email = $_POST["email"];
$delivery = $_POST["deladdress"];
$delivery = array_shift($delivery); // sobe um nivel as posiçoes do array, em vez de usar $array[0]['bla'] , usasse so $array['bla']
$data2 = array();
$data2 = $this->model_account_customer->getCustomerByEmail($email);
$Method = $_POST["PayMethod"];
$TotalCheckout = $_POST["TotalCheck"];
$IP = $_POST["IP"];
$Agent = $_POST["User"];
$Products = $_POST["Prod"];
$length = count($Products);
for ($i = 0; $i < $length; $i++) {
(int)$datap[$i]['product_id'] = $Products[$i]['Id'];
$datap[$i]['name'] = $Products[$i]['Name'];
$datap[$i]['model'] = $Products[$i]['modelo'];
(int)$datap[$i]['quantity'] = $Products[$i]['NItems'];
$datap[$i]['price'] = $Products[$i]['Preco'];
$datap[$i]['total'] = $Products[$i]['Total'];
$datap[$i]['tax'] = 0; //$Products[$i]['Tax'];
(int)$datap[$i]['reward'] = 0; //$Products[$i]['Reward'];
}
$url = $myurl;
$data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
$data['store_id'] = $this->config->get('config_store_id');
$data['store_name'] = "Loja Teste";
$data['store_url'] = $url;
$data['firstname'] = $data2['firstname'] ;
$data['lastname'] = $data2['lastname'];
$data['email'] = $data2['email'];
$data['telephone'] = $data2['telephone'];
$data['fax'] = $data2['fax'];
$data['payment_firstname'] = $delivery['firstname'];
$data['payment_lastname'] = $delivery['lastname'];
$data['payment_company'] = $delivery['company'];
$data['payment_company_id'] = $delivery['company_id'];;
$data['tax_id'] = $delivery['tax_id'];
$data['payment_address_1'] = $delivery['address_1'];
$data['payment_address_2'] = $delivery['address_2'];
$data['payment_city'] = $delivery['city'];
$data['payment_postcode'] = $delivery['postcode'];
$data['payment_country'] = $delivery['country'];
$data['payment_country_id'] = $delivery['country_id'];
$data['payment_zone'] = $delivery['zone'];
$data['payment_zone_id'] = $delivery['zone_id'];
$data['payment_method'] = "Cash On Delivery";
$data['payment_code'] = 1;
$data['total'] = $TotalCheckout;
//NOTA: esta duas variaveis abaixo servem para tratar dos preços, alterar depois para quando a loja tiver opçoes de escolher preços
$data['language_id'] = (int)$this->config->get('config_language_id');
$data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
$data['currency_id'] = (int)2;
$data['currency_code'] = "USD";
$data['currency_value'] = (float)1.00000000;
$data['ip'] = $IP;
$data['forwarded_ip'] = $IP;
$data['user_agent'] = $Agent;
$data['products'] = $datap;
(int)$order = $this->model_checkout_order->addOrder($data);
$this->model_checkout_order->confirm($order, 1 , $comment = '', $notify = false);
echo ("teste");
}
}

Related

Product id (multisite setup)

We are building a script that makes an xml export of orders. In the export, we need to get the EAN code of the product that has been ordered. Currently we use WooCommerce to get the product info, and get the _sku from there.
However, we notice something is going wrong with our multisite setup.
When a product is ordered from site B, we sometimes are unable to get the EAN code of the ordered product, or get a wrong EAN code.
This because if we use our script and ask WooCommerce -> getOrder -> getItems, we get the product id's from site A, not site B. So when we try to get the _sku info from an ordered item, it's looking for the wrong product.
How can we make sure that with our script, it knows what _sku to take when we get our order information so that it doesn't matter which site the order came from, the order information is always correct?
function bol_2020_custom_process_order_manual($order_id) {
global $voorletters;
$order = new WC_Order( $order_id );
// $myuser_id = (int)$order->user_id;
// $user_info = get_userdata($myuser_id);
// $customer = new WC_Customer($order_id);
$items = $order->get_items();
$xml_order_id = $order_id;
$xml_ORDER_DATE = date('Y-m-d');
$xml_DELIVERY_START_DATE = '2017-09-07';
$xml_DELIVERY_END_DATE = '2017-09-08';
$xml_SUPPLIER_NAME = 'DOMAINNAME.nl';
$xml_SUPPLIER_NAME2 = '';
$xml_SUPPLIER_NAME3 = '';
$xml_SUPPLIER_STREET = '**** 71A';
$xml_SUPPLIER_ZIP = '******';
$xml_SUPPLIER_CITY = '********';
$xml_SUPPLIER_COUNTRY = 'NL';
$xml_BUYUR_NAME = get_post_meta($order_id,'_shipping_first_name',true).' '.get_post_meta($order_id,'_shipping_last_name',true);
$xml_BUYUR_NAME2 = get_post_meta($order_id,'_shipping_company',true);
$xml_BUYUR_NAME3 = '';
$xml_BUYUR_STREET = get_post_meta($order_id,'_shipping_address_1',true).' '.get_post_meta($order_id,'_shipping_address_2',true);
$xml_BUYUR_ZIP = get_post_meta($order_id,'_shipping_postcode',true);
$xml_BUYUR_CITY = get_post_meta($order_id,'_shipping_city',true);
$xml_BUYUR_COUNTRY = get_post_meta($order_id,'_shipping_country',true);
$imp = new DOMImplementation;
$dtd = $imp->createDocumentType('ORDER', '', 'openTRANS_ORDER_1_0.dtd');
$dom = $imp->createDocument("", "", $dtd);
$dom->encoding = 'UTF-8';
$root = $dom->appendChild($root = $dom->createElement('ORDER'));
$order_version = $root->appendChild($dom->createAttribute('version'));
$order_version->value = '1.0';
$order_type = $root->appendChild($dom->createAttribute('type'));
$order_type->value = 'standard';
$root->appendChild($client = $dom->createElement('ORDER_HEADER'));
$order_info = $client->appendChild($dom->createElement('ORDER_INFO'));
$order_info->appendChild($ORDER_ID = $order_info->appendChild($dom->createElement('ORDER_ID')));
$ORDER_ID->appendChild($dom->createTextNode($voorletters.$xml_order_id));
$order_info->appendChild($ALT_CUSTOMER_ORDER_ID = $order_info->appendChild($dom->createElement('ALT_CUSTOMER_ORDER_ID')));
$ALT_CUSTOMER_ORDER_ID->appendChild($dom->createTextNode(''));
$order_info->appendChild($ORDER_DATE = $order_info->appendChild($dom->createElement('ORDER_DATE')));
$ORDER_DATE->appendChild($dom->createTextNode($xml_ORDER_DATE));
$DELIVERY_DATE = $order_info->appendChild($order_info->appendChild($dom->createElement('DELIVERY_DATE')));
$DELIVERY_DATE_ATT = $DELIVERY_DATE->appendChild($dom->createAttribute('type'));
$DELIVERY_DATE_ATT->value = 'fixed';
$DELIVERY_START_DATE = $DELIVERY_DATE->appendChild($dom->createElement('DELIVERY_START_DATE'));
$DELIVERY_START_DATE->appendChild($dom->createTextNode($xml_DELIVERY_START_DATE));
$DELIVERY_END_DATE = $DELIVERY_DATE->appendChild($dom->createElement('DELIVERY_END_DATE'));
$DELIVERY_END_DATE->appendChild($dom->createTextNode($xml_DELIVERY_END_DATE));
$ORDER_PARTIES = $order_info->appendChild($order_info->appendChild($dom->createElement('ORDER_PARTIES')));
$BUYER_PARTY = $ORDER_PARTIES->appendChild($dom->createElement('BUYER_PARTY'));
$PARTY_ID = $BUYER_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID_ = $PARTY_ID->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID__ATT = $PARTY_ID_->appendChild($dom->createAttribute('type'));
$PARTY_ID__ATT->value = 'ILN';
//$PARTY_ID_->appendChild($dom->createTextNode('4317784032988'));
$PARTY_ID_->appendChild($dom->createTextNode('4317784044110'));
$SUPPLIER_PARTY = $ORDER_PARTIES->appendChild($dom->createElement('SUPPLIER_PARTY'));
$PARTY_ID = $SUPPLIER_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID_ = $PARTY_ID->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID__ATT = $PARTY_ID_->appendChild($dom->createAttribute('type'));
$PARTY_ID__ATT->value = 'ILN';
$PARTY_ID_->appendChild($dom->createTextNode('4317784000000'));
$SHIPMENT_PARTIES = $ORDER_PARTIES->appendChild($dom->createElement('SHIPMENT_PARTIES'));
$DELIVERY_PARTY = $SHIPMENT_PARTIES->appendChild($dom->createElement('DELIVERY_PARTY'));
$PARTY = $DELIVERY_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID = $PARTY->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID_ATT = $PARTY_ID->appendChild($dom->createAttribute('type'));
$PARTY_ID_ATT->value = 'supplier_specific';
$PARTY_ID->appendChild($dom->createTextNode(''));
$ADDRESS = $PARTY->appendChild($dom->createElement('ADDRESS'));
$NAME = $ADDRESS->appendChild($dom->createElement('NAME'));
$NAME->appendChild($dom->createTextNode($xml_SUPPLIER_NAME));
$NAME2 = $ADDRESS->appendChild($dom->createElement('NAME2'));
$NAME2->appendChild($dom->createTextNode($xml_SUPPLIER_NAME2));
$NAME3 = $ADDRESS->appendChild($dom->createElement('NAME3'));
$NAME3->appendChild($dom->createTextNode($xml_SUPPLIER_NAME3));
$STREET = $ADDRESS->appendChild($dom->createElement('STREET'));
$STREET->appendChild($dom->createTextNode($xml_SUPPLIER_STREET));
$ZIP = $ADDRESS->appendChild($dom->createElement('ZIP'));
$ZIP->appendChild($dom->createTextNode($xml_SUPPLIER_ZIP));
$CITY = $ADDRESS->appendChild($dom->createElement('CITY'));
$CITY->appendChild($dom->createTextNode($xml_SUPPLIER_CITY));
$COUNTRY = $ADDRESS->appendChild($dom->createElement('COUNTRY'));
$COUNTRY->appendChild($dom->createTextNode($xml_SUPPLIER_COUNTRY));
$FINAL_DELIVERY_PARTY = $SHIPMENT_PARTIES->appendChild($dom->createElement('FINAL_DELIVERY_PARTY'));
$PARTY = $FINAL_DELIVERY_PARTY->appendChild($dom->createElement('PARTY'));
$PARTY_ID = $PARTY->appendChild($dom->createElement('PARTY_ID'));
$PARTY_ID_ATT = $PARTY_ID->appendChild($dom->createAttribute('type'));
$PARTY_ID_ATT->value = 'buyer_specific';
$PARTY_ID->appendChild($dom->createTextNode(''));
$ADDRESS = $PARTY->appendChild($dom->createElement('ADDRESS'));
$NAME = $ADDRESS->appendChild($dom->createElement('NAME'));
$NAME->appendChild($dom->createTextNode($xml_BUYUR_NAME));
$NAME2 = $ADDRESS->appendChild($dom->createElement('NAME2'));
$NAME2->appendChild($dom->createTextNode($xml_BUYUR_NAME2));
$NAME3 = $ADDRESS->appendChild($dom->createElement('NAME3'));
$NAME3->appendChild($dom->createTextNode($xml_BUYUR_NAME3));
$STREET = $ADDRESS->appendChild($dom->createElement('STREET'));
$STREET->appendChild($dom->createTextNode($xml_BUYUR_STREET));
$ZIP = $ADDRESS->appendChild($dom->createElement('ZIP'));
$ZIP->appendChild($dom->createTextNode($xml_BUYUR_ZIP));
$CITY = $ADDRESS->appendChild($dom->createElement('CITY'));
$CITY->appendChild($dom->createTextNode($xml_BUYUR_CITY));
$COUNTRY = $ADDRESS->appendChild($dom->createElement('COUNTRY'));
$COUNTRY->appendChild($dom->createTextNode($xml_BUYUR_COUNTRY));
$PARTIAL_SHIPMENT_ALLOWED = $order_info->appendChild($order_info->appendChild($dom->createElement('PARTIAL_SHIPMENT_ALLOWED')));
$PARTIAL_SHIPMENT_ALLOWED->appendChild($dom->createTextNode('False'));
$TRANSPORT = $order_info->appendChild($order_info->appendChild($dom->createElement('TRANSPORT')));
$INCOTERM = $TRANSPORT->appendChild($dom->createElement('INCOTERM'));
$INCOTERM->appendChild($dom->createTextNode(''));
$LOCATION = $TRANSPORT->appendChild($dom->createElement('LOCATION'));
$LOCATION->appendChild($dom->createTextNode('EKD'));
$TRANSPORT_REMARK = $TRANSPORT->appendChild($dom->createElement('TRANSPORT_REMARK'));
$TRANSPORT_REMARK->appendChild($dom->createTextNode('10'));
$REMARK_GENERAL = $order_info->appendChild($order_info->appendChild($dom->createElement('REMARK')));
$REMARK_GENERAL_ = $REMARK_GENERAL->appendChild($dom->createAttribute('type'));
$REMARK_GENERAL_->value = 'general';
$REMARK_GENERAL->appendChild($dom->createTextNode('SUPERHANDIG.NL IS HÉT ADRES VOOR PROF. GEREEDSCHAP EN ACCESSOIRES!'));
$REMARK_ORDER = $order_info->appendChild($order_info->appendChild($dom->createElement('REMARK')));
$REMARK_ORDER_ = $REMARK_ORDER->appendChild($dom->createAttribute('type'));
$REMARK_ORDER_->value = 'order';
$REMARK_ORDER->appendChild($dom->createTextNode($voorletters.$xml_order_id));
$ORDER_ITEM_LIST = $root->appendChild($client = $dom->createElement('ORDER_ITEM_LIST'));
$i = 0;
foreach ($items as $item) {
$ean = get_post_meta($item['product_id'], '_sku'); // for single products
$qty = $item['qty'];
if(empty($ean[0])){
$ean = get_post_meta($item['variation_id'], '_sku'); // for variable products
}
$i++;
$ORDER_ITEM = $ORDER_ITEM_LIST->appendChild($dom->createElement('ORDER_ITEM'));
$LINE_ITEM_ID = $ORDER_ITEM->appendChild($dom->createElement('LINE_ITEM_ID'));
$LINE_ITEM_ID->appendChild($dom->createTextNode($i));
$ARTICLE_ID = $ORDER_ITEM->appendChild($dom->createElement('ARTICLE_ID'));
$SUPPLIER_AID = $ARTICLE_ID->appendChild($dom->createElement('SUPPLIER_AID'));
$SUPPLIER_AID->appendChild($dom->createTextNode(''));
$INTERNATIONAL_AID = $ARTICLE_ID->appendChild($dom->createElement('INTERNATIONAL_AID'));
$INTERNATIONAL_AID_ = $INTERNATIONAL_AID->appendChild($dom->createAttribute('type'));
$INTERNATIONAL_AID_->value = 'EAN';
$INTERNATIONAL_AID->appendChild($dom->createTextNode($ean[0]));
$BUYER_AID = $ARTICLE_ID->appendChild($dom->createElement('BUYER_AID'));
$BUYER_AID_ = $BUYER_AID->appendChild($dom->createAttribute('type'));
$BUYER_AID_->value = 'BP';
$BUYER_AID->appendChild($dom->createTextNode(''));
$BUYER_AID = $ARTICLE_ID->appendChild($dom->createElement('BUYER_AID'));
$BUYER_AID_ = $BUYER_AID->appendChild($dom->createAttribute('type'));
$BUYER_AID_->value = 'IN';
$BUYER_AID->appendChild($dom->createTextNode(''));
$DESCRIPTION_SHORT = $ARTICLE_ID->appendChild($dom->createElement('DESCRIPTION_SHORT'));
$DESCRIPTION_SHORT->appendChild($dom->createTextNode(''));
$QUANTITY = $ORDER_ITEM->appendChild($dom->createElement('QUANTITY'));
$QUANTITY->appendChild($dom->createTextNode($qty));
$ORDER_UNIT = $ORDER_ITEM->appendChild($dom->createElement('ORDER_UNIT'));
$ORDER_UNIT->appendChild($dom->createTextNode('C62'));
}
$ORDER_SUMMARY = $root->appendChild($client = $dom->createElement('ORDER_SUMMARY'));
$TOTAL_ITEM_NUM = $ORDER_SUMMARY->appendChild($dom->createElement('TOTAL_ITEM_NUM'));
$TOTAL_ITEM_NUM->appendChild($dom->createTextNode($i));
$dom->formatOutput = true;
$dom->save($_SERVER['DOCUMENT_ROOT'].'/ede_orders/xml/'.$voorletters.$xml_order_id.'.xml');
}
https://gist.github.com/webstylecenter/2491735366a70d82336512e0d0cc4e8f

Product (........ ) is over.PrestaShop 1.7

When added from a third-party product to the cart. I want to change the quantity of goods in the basket. Get alert Product (........ ) is over.
if(is_array($arCartPrice)){
//if($arCartPrice['OPTIONS']['MINIMUM']>1){$QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];}else{$QUANTITY=1;}
$QUANTITY=$arCartPrice['AVAILABLE_NUM'];
$DefaultCategory = 12;
$DefaultTaxGroup = 0;
$Price = $arCartPrice['PRICE_CONVERTED'];
$PriceVAT = round($Price);
$Reference = $arCartPrice['ARTICLE'].' / '.$arCartPrice['BRAND'];
//Presta init
global $context;
if(!$context){$context = Context::getContext();}
$logged = $context->cookie->__get('logged');
$id_cart = $context->cookie->__get('id_cart');
$id_lang = $context->cookie->__get('id_lang');
$id_guest = $context->cookie->__get('id_guest');
$id_currency = $context->cookie->__get('id_currency');
// Add cart if no cart found
if (!$id_cart){
$context->cart = new Cart();
$context->cart->id_customer = $context->customer->id;
$context->cart->id_currency = $id_currency;
$context->cart->add();
if($context->cart->id){
$context->cookie->id_cart = (int)$context->cart->id;
}
$id_cart = (int)$context->cart->id;
}
$doAdd="Y";
//if(!$logged>0){$doAdd="N"; $TCore->arErrorMessages[] = 'You must be logged in to buy products';}
//if(trim($Reference)=='' OR !$Price>0 OR !$QUANTITY>0){$doAdd="N"; $TCore->arErrorMessages[] = 'Add to cart data is missing!';}
if(!$id_cart>0){$doAdd="N"; ErAdd("Your cookie <b>id_cart</b> is wrong!",1);}
if(!$id_lang>0){$doAdd="N"; ErAdd("Your cookie <b>id_lang</b> is wrong!",1);}
if($doAdd!="N"){
//Check avail. tecdoc item in Presta
$sql = 'SELECT p.`id_product`, pl.`name` FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`)
WHERE pl.`id_lang` = '.$id_lang.' AND
p.`price` = '.$Price.' AND
p.`reference` = "'.$Reference.'"
';
$arRes = Db::getInstance()->executeS($sql);
if(count($arRes)>0){
$NewTID = $arRes[0]['id_product'];
}else{
//Supplier data (for 1C integration)
$supplierName = $arCartPrice['SUPPLIER_STOCK'];
$supplierId = $suppliers = (Supplier::getIdByName($supplierName));
if (!$supplierId) {
$supplier = new Supplier();
$supplier->name = $supplierName;
$supplier->active = 1;
$supplier->add();
$supplierId = $supplier->id;
}
$obProduct = new Product(false,false,$id_lang);
$obProduct->id_category_default = $DefaultCategory;
$obProduct->unity = $arCartPrice['ADD_URL'];
$obProduct->name = $arCartPrice['ARTICLE'] .' / '.substr($arCartPrice['NAME'],0,400).' / '.$arCartPrice['BRAND'];
$obProduct->description = 'This product is created automatically by ';
$obProduct->description_short = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]';
$obProduct->price = $Price;
$obProduct->wholesale_price = $arCartPrice['PRICE'];
$obProduct->reference = $Reference;
$obProduct->link_rewrite = $arCartPrice['CPID'];
$obProduct->available_for_order = 1; //true
$obProduct->visibility = 'none';
$obProduct->is_virtual = 0;
//$obProduct->weight = round($arCartPrice['OPTIONS']['WEIGHT']/1000,2);
$obProduct->minimal_quantity = 1;
$obProduct->condition = 'used';
$obProduct->condition = 'refurbished';
$obProduct->available_now = $arCartPrice['AVAILABLE_NUM'];
$obProduct->quantity = $arCartPrice['AVAILABLE_NUM'];
//supplier
$obProduct->supplier_name = $supplierName;
$obProduct->id_supplier = $supplierId;
$obProduct->id_tax_rules_group = $DefaultTaxGroup;
//echo '<br><pre>';print_r($obProduct);echo '</pre>';die();
$obProduct->add();
if($obProduct->id>0){
$NewTID = $obProduct->id;
$obProduct->setWsCategories(Array(Array("id"=>$DefaultCategory)));
//Add image
if($arCartPrice['IMG_SRC']!='' AND $NewTID>0){
$shops = Shop::getShops(true, null, true);
$image = new Image();
$image->id_product = $NewTID;
$image->position = Image::getHighestPosition($NewTID)+1;
$image->cover = true; // or false;
if(($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){
$image->associateTo($shops);
$tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
if(Tools::copy($arCartPrice['IMG_SRC'], $tmpfile)){
$path = $image->getPathForCreation();
ImageManager::resize($tmpfile, $path.'.jpg');
}
unlink($tmpfile);
}
}
}else{
ErAdd("Prestashop new Item ID is false",1);
}
unset($obProduct);
}
if($NewTID>0){
//if($arCartPrice['AVAILABLE']>0){StockAvailable::setQuantity($NewTID, false, $arCartPrice['AVAILABLE']);}
StockAvailable::setQuantity($NewTID, 0, (int) $arCartPrice['AVAILABLE']);
$obCart = new Cart($id_cart);
$obCart->id_lang = $id_lang;
$obCart->id_currency = $id_currency;
if($obCart->updateQty((int)$QUANTITY=1, (int)$NewTID)){
Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); die();
}else{
ErAdd(" Add to Cart is false. NewTID=".$NewTID,1);
}
How to fix the code so you can update the quantity of goods in your cart.
And the number of 10 pieces. 1 piece is added to the cart. I want to add more to my cart. How to implement it? When I add 2 pieces. I receive a message Product (........ ) is over..
enter image description here
First of all, after you created the product, check in the Backoffice if the quantity is well stored (If the newly created product quantity is equal with $arCartPrice['AVAILABLE_NUM'] )
Maybe you can try with enabled "Allow ordering when out of stock" .

How to get percentage referral comission in laravel?

i have this script which give referral commission to referr in a fix amount e.g 10$ per referral. if referred person deposit amount on website.
want 10% of referred person deposited amount to referrer.
simple : how to configure $ref['balance'] for percentage
i have tried it to multiply and divide by hundered but not work
$refer = Auth::user()->under_reference;
if($basic->reference_id == $refer){
$ref['user_id'] = 0;
$ref['reference_id'] = $basic->reference_id;
$ref['under_reference'] = $user->reference;
$ref['balance'] = ( $request->id * $basic->reference ) / 100;
$ref['details'] = "Referral Invest Bonus : ".$ref['balance']."; ".$basic->currency.' Referral ID : # '.$ref['under_reference'];
$ref['old_balance'] = $basic->admin_total;
$ref['new_balance'] = $basic->admin_total;
Reference::create($ref);
//admin reference Log
$ad['user_id'] = 0;
$ad['balance_type'] = 5;
$ad['balance'] = $ref['balance'];
$ad['old_balance'] = $ref['old_balance'];
$ad['new_balance'] = $ref['old_balance'];
$ad['details'] = $ref['details'];
$ad['charge'] = "Default";
AdminBalance::create($ad);
//admin balance log
$ad['user_id'] = Auth::user()->id;
$ad['balance_type'] = 2;
$ad['balance'] = $request->id;
$ad['old_balance'] = $basic->admin_total;
$ad['new_balance'] = $basic->admin_total + $request->id;
$ad['details'] = "Invest ID: # ".$dep['deposit_number'].'; '."Invest Plan : ".$plan->name;
AdminBalance::create($ad);
$basic->admin_total = $ad['new_balance'];
$basic->save();
}else{
/* ---------- Reference Log ---------*/
$rrrr = User::whereReference(Auth::user()->under_reference)->first();
$ref['user_id'] = $rrrr->id;
$ref['reference_id'] = $rrrr->reference;
$ref['under_reference'] = $user->reference;
$ref['balance'] = ( $request->id * $basic->reference ) / 100;
$ref['details'] = "Referral Invest Bonus : ".$ref['balance']."-".$basic->currency."; ".' Referral ID : # '.$ref['under_reference'];
$ref['old_balance'] = $rrrr->amount;
$ref['new_balance'] = $rrrr->amount + $ref['balance'];
Reference::create($ref);
/*---- User reference Log ----*/
$ad1['user_id'] = $rrrr->id;
$ad1['balance_type'] = 5;
$ad1['balance'] = $ref['balance'];
$ad1['old_balance'] = $rrrr->amount;
$ad1['new_balance'] = $rrrr->amount + $ad1['balance'];
$ad1['details'] = $ref['details'];
UserBalance::create($ad1);
$rrrr->amount = $ref['new_balance'];
$rrrr->save();
/* ------ Admin reference Log -------*/
$ad['user_id'] = $rrrr->id;
$ad['balance_type'] = 5;
$ad['balance'] = $ref['balance'];
$ad['old_balance'] = $basic->admin_total;
$ad['new_balance'] = $basic->admin_total - $ad['balance'];
$ad['details'] = $ref['details'];
AdminBalance::create($ad);
$basic->admin_total = $ad['new_balance'];
$basic->save();

Adding recurring payments to Paypal on an existing website coded in PHP?

I'm not really familiar with PHP. I've been asked to add a recurring payment option to an already existing website that charges subscriptions to a magazine. Looking at the code I found this section:
$paypal = new Paypal('en');
$paypal->API_UserName = API_USERNAME;
$paypal->API_Password = API_PASSWORD;
$paypal->API_Signature = API_SIGNATURE;
$paypal->API_Endpoint = 'https://api-3t.paypal.com/nvp' ;
$paypal->lang_id = 'en';
$paypal->country_code = 'CA';
$paypal->operation = OPERATION;
$paypal->payment_type = PAYMENT_TYPE;
$paypal->email = $Subscription->email;
$paypal->firstname = $Subscription->first_name;
$paypal->lastname = $Subscription->last_name;
$paypal->address = $Subscription->address;
$paypal->city = $Subscription->city;
$paypal->state = $Subscription->province;
$paypal->zip = $Subscription->postal_code;
$paypal->ship_address = $paypal-> address;
$paypal->ship_firstname = $paypal-> firstname;
$paypal->ship_lastname = $paypal-> lastname;
$paypal->ship_city = $paypal-> city;
$paypal->ship_state = $paypal-> state;
$paypal->ship_country_code = $paypal-> country_code;
$paypal->ship_zip = $paypal-> zip;
$paypal->credit_card_type = POST( 'card_type' );
$paypal->credit_card_number = POST( 'card_number' );
$paypal->exp_month = POST( 'card_month' );
$paypal->exp_year = POST( 'card_year' );
$paypal->cvn = POST( 'cvn' );
$paypal->amount = number_format((float)$Subscription->total, 2);
//$paypal->items_amount = number_format((float)$Subscription->price, 2);
$paypal->shipping_amount = 0;
//$paypal->tax_amount = number_format((float)$Subscription->taxes, 2);
$paypal->currency_code = 'CAD';
$paypal->prepare_checkout_request();
$paypal->process_request();
$paypal->interpret_response();
Looking at the Paypal documentation I found these parameters that should add the recurring feature to the current payment:
PROFILESTARTDATE
BILLINGPERIOD
BILLINGFREQUENCY
AMT
How could I fit these in the current structure to, for example, make it charge every 3 years?
Thanks for any info that could guide me!
PS, for this, do customers need a Paypal account? Or can they just put their credit card?

Shipping Address not displayed in the Paypal Transaction Details page

I am unable to get the shipping Addresses of my customers in the 'Transacton Details' page.
It's displaying the following message.
'We have no shipping address on file'
The issue mainly happens when users use PaypalPro (Direct Payment) option.
Can anyone help me in this issue.
Note:
This is my code corresponding to the DoDirectPayment Request.
class ProAuthorizeRequest extends AbstractRequest
{
protected $action = 'Authorization';
public function getData()
{
$data = $this->getBaseData('DoDirectPayment');
$this->validate('amount', 'card');
$this->getCard()->validate();
$data['PAYMENTACTION'] = $this->action;
$data['AMT'] = $this->getAmount();
$data['CURRENCYCODE'] = $this->getCurrency();
$data['INVNUM'] = $this->getTransactionId();
$data['DESC'] = $this->getDescription();
// add credit card details
$data['ACCT'] = $this->getCard()->getNumber();
$data['CREDITCARDTYPE'] = $this->getCard()->getBrand();
$data['EXPDATE'] = $this->getCard()->getExpiryMonth().$this->getCard()->getExpiryYear();
$data['STARTDATE'] = $this->getCard()->getStartMonth().$this->getCard()->getStartYear();
$data['CVV2'] = $this->getCard()->getCvv();
$data['ISSUENUMBER'] = $this->getCard()->getIssueNumber();
$data['IPADDRESS'] = $this->getClientIp();
$data['FIRSTNAME'] = $this->getCard()->getFirstName();
$data['LASTNAME'] = $this->getCard()->getLastName();
$data['EMAIL'] = $this->getCard()->getEmail();
$data['STREET'] = $this->getCard()->getAddress1();
$data['STREET2'] = $this->getCard()->getAddress2();
$data['CITY'] = $this->getCard()->getCity();
$data['STATE'] = $this->getCard()->getState();
$data['ZIP'] = $this->getCard()->getPostcode();
$data['COUNTRYCODE'] = strtoupper($this->getCard()->getCountry());
return $data;
}
}
For DoDirectPayment you need to also include the SHIPTO variables:
public function getData()
{
$data = $this->getBaseData('DoDirectPayment');
$this->validate('amount', 'card');
$this->getCard()->validate();
$data['PAYMENTACTION'] = $this->action;
$data['AMT'] = $this->getAmount();
$data['CURRENCYCODE'] = $this->getCurrency();
$data['INVNUM'] = $this->getTransactionId();
$data['DESC'] = $this->getDescription();
// add credit card details
$data['ACCT'] = $this->getCard()->getNumber();
$data['CREDITCARDTYPE'] = $this->getCard()->getBrand();
$data['EXPDATE'] = $this->getCard()->getExpiryMonth().$this->getCard()->getExpiryYear();
$data['STARTDATE'] = $this->getCard()->getStartMonth().$this->getCard()->getStartYear();
$data['CVV2'] = $this->getCard()->getCvv();
$data['ISSUENUMBER'] = $this->getCard()->getIssueNumber();
$data['IPADDRESS'] = $this->getClientIp();
$data['FIRSTNAME'] = $this->getCard()->getFirstName();
$data['LASTNAME'] = $this->getCard()->getLastName();
$data['EMAIL'] = $this->getCard()->getEmail();
$data['STREET'] = $this->getCard()->getAddress1();
$data['STREET2'] = $this->getCard()->getAddress2();
$data['CITY'] = $this->getCard()->getCity();
$data['STATE'] = $this->getCard()->getState();
$data['ZIP'] = $this->getCard()->getPostcode();
$data['COUNTRYCODE'] = strtoupper($this->getCard()->getCountry());
//shipping information as you want displayed on transaction details. name is a single field.
$data['SHIPTONAME'] = $this->getCard()->getFirstName() . " " . $this->getCard()->getLastName();
$data['SHIPTOSTREET'] = $this->getCard()->getAddress1();
$data['SHIPTOSTREET2'] = $this->getCard()->getAddress2();
$data['SHIPTOCITY'] = $this->getCard()->getCity();
$data['SHIPTOSTATE'] = $this->getCard()->getState();
$data['SHIPTOZIP'] = $this->getCard()->getPostcode();
$data['SHIPTOCOUNTRYCODE'] = strtoupper($this->getCard()->getCountry());
return $data;
}

Categories