I am trying to create new customer with shipping address and then want them to redirect to a page to show "Thank You" or "Error" message. I have used:
$createFields = array(
'first_name'=>$first_name,
'last_name'=>$last_name,
'email'=>$email,
'company'=>$company,
'phone'=>$phone,
'addresses'=>array(
'first_name'=>$first_name,
'last_name'=>$last_name,
'phone'=>$phone,
'street_1'=>$street_1,
'city'=>'',
'state'=>'',
'zip'=>'',
'country'=>''
)
);
$customers = Bigcommerce::createCustomer($createFields);
to create customer but it's not working at all. Once I remove 'addresses' field, new customer get created.
Can anyone help me telling how can I add address with customer? Also how can I check whether customer has been created properly or not?
It may happen customer tries to re-register himself - the system should show error "email already exists".
I am new to Bigcommerce API - any help will be appreciated.
Thanks
In the Bigcommerce class Client.php, you can find that exist a method named: createCustomerAddress. You just need to pass it the customer id and the address single array that you want to add.
An example of this could be:
$address = array(
'country'=>'United States',
'first_name'=>'First',
'last_name'=>'Last',
'street_1'=>'5543 Ave34',
'city'=>'Miami',
'state'=>'Florida',
'zip'=>'54023',
'phone'=>'783 000 0000'
);
Bigcommerce::createCustomerAddress($customer_id, $address);
Related
Hello to all the community,
Thank you in advance to whoever will take the time to answer me ๐!
In fact, I want to find a solution to make the minimum purchase on the checkout page ( not on the cart page ) and it depends on the address city.
I already did it in Prestashop 1.6 but now I use Prestashop 1.7.7.1 I am obliged to override the cart Presenter but I didn't rich a convenient solution.
Even I purchased a module of minimum purchase by country and modified it to be by the city but the module itself is not stable and it didn't work properly and the support of the module cannot find a solution because it requires an override of the core of Prestashop in the Symfony code and it will affect all the order tunnel which is typically impossible.
This topic will be a real challenge for developers that they don't know the impossible ๐!
Thanks in advance.
Assuming you are creating a module, in CartPresenter class you have hook overrideMinimalPurchasePrice. You can hook your module to this hook and modify the $minimalPurchase value in your module according to your logic.
You said that price depends on the address's city. Well, in your hook you can get the address, because in Prestashop front-office you always have access to cart and cart might have delivery address id:
public function hookOverrideMinimalPurchasePrice($params)
{
$cart = $this->context->cart;
$id_address = $cart->id_address_delivery;
// If customer did not enter the address yet, the address id is 0.
if($id_address != 0)
{
$address = new Address($id_address);
$city = $address->city;
if($city == 'New York')
$params['minimalPurchase'] = 100;
}
}
}
You do not have to return anything in the hook, because in CartPresenter.php the hook is called with parameter being passed by reference:
Hook::exec('overrideMinimalPurchasePrice', [
'minimalPurchase' => &$minimalPurchase,
]);
I'm following the external APIs documentation : https://www.odoo.com/documentation/13.0/webservices/odoo.html
to implement our companies requirements. I'm required to create a sales order and automatically create an invoice after that. The sales order part is done but I cant seem to be able to attach the Invoice to the Sales order
I've tried linking it via the 'invoice_ids' field but the documentation does not mention how to provide a many2many field in it. here is the code:
many2manyInvoice = [(4, invoice_id)]
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
#Admin user Id
uid = common.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
models.execute_kw(db, uid, password, 'sale.order', 'write', [[sales_order_id], {'invoice_ids':many2manyInvoice}])
The response returned is 200 , but nothing is happening on the sales order level. I think its the way that I defined the field that might be incorrect.
Can someone help with this issue ? Thanks in advance
Nothing is happening on the sales order level because you are not creating a sales record, writing to it without doing anything. Not sure if this would work in your specific case but here is what I would do.
Use the Pro-forma invoice https://www.odoo.com/documentation/user/13.0/sales/invoicing/proforma.html
Then when a sales record is created run the "Send pro-forma invoice" method using the web api. This takes care of the db linking, as it can get very complicated.
I am developing a module that get user data in a page , I wand to submit this data to prestashop database to create a new user account .
so how can I do this ?
how should I understand what data I should get from user Like email,phone number and etc . (I want to know this Shop get what data from user to sign them up).
thank you
You can use this piece of code to create a Customer.
$customer = new Customer();
$customer->firstname = 'John';
$customer->lastname = 'Doe';
$customer->email = 'johndoe#gmail.com';
$customer->passwd = md5(pSQL(_COOKIE_KEY_.'yoursecretpasswordhere'));
$customer->save();
Like Madhi said, you will get all information needed for the Customer in Customer.php
Cheers :)
All the things you need are defined in the "classes/Customer.php" file.
Each PrestShop class has one "public static $definition" and each field of the $definition that has the "'required' => true", is required
I'm using Prestashop 1.5 and created page with list of grouped products. I want to show quantity of each product in the cart. At shopping cart page exist $product.cart_quantity property, but on my page it doesn't. Please, explain me, how to show product quantity in the cart on my page.
Easyest way I can think of is to access the data via cookies since cart data is stored in them.
You can get cookies data like this:
$context = Context::getContext();
echo '<pre>',print_r($context->cookie, true).'</pre>';
Prestashop Context is a registry for PHP variables that were previously accessed as globals. It aims to standardize the way these variables are accessed, and to make the code more robust by getting rid of global vars.
And our echo is just for example to show what info you can get from cookies.
When costumer adds something to the shopping-cart it automatically gives it a cart id (id_cart) and from there it's fairly easy to access to access that value to get all the info.
To get a cart id ( assuming you already got context ) use this
$Cart = $context->cart;
This returns you a ID of a current cart.
Now you want to return the current products in the cart ( with all the information it includes ). For that you have to use the public function located in prestashop_main_folder/classes/cart.php
So to return all the current products just use the following line
$Cart->getProducts($refresh = false, $id_product = false, $id_country = null)
And then it returns you a array with all the variables what you can easily then access.
BR's
You can do the following:
$context=Context::getContext();
$id_cart=$context->cookie->id_cart;
if($id_cart=='') $id_cart=Tools::getValue('id_cart');
$theCart = new Cart($id_cart);
$products = $theCart->getProducts(true);
$nbTotalProducts = 0;
foreach ($products as $product)
{
$nbTotalProducts += (int)$product['cart_quantity'];
}
In magento, when a person becomes a member, the date "created_at" is saved with the profile.
How can I retrieve this information from magento. I can get the address info etc. but can't work out how to display / get the date a user created its account.
I tried the following:
echo Mage::getResourceModel('customer/customer_collection')->addAttributeToSelect('crโโeated_at');
But doesn't work.
Thanks.
Did you try this:
$customer = Mage::getModel('customer/customer')->load(IDHERE);
//or
$customer = Mage::getModel('customer/customer')->loadByEmail('test#test.com');
echo $customer->getCreatedAtTimestamp();
where exactly are you trying to get this? from within the customers session? or are you trying to get an arbitrary customer, rather than the current customer?