How to know if my carrier is pick up in-store - prestashop

I have a prestashop module in which they are asking me in a parameter to indicate if the carrier that was chosen is to pick up in store or not. I am getting the carrier information in this way
$carrier = new Carrier($cart->id_carrier);
This brings me the information of the carrier correctly, the problem is that the only parameter I see to know if it is pick up or not is delay, but this is a parameter which you can always change the value in the carrier configuration.
When creating the store in prestashop this creates 2 carrier by default, one is the pick up in-store, but if I delete this carrier and then I want to create another custom that is pick up in-store, prestashop does not provide a specific option to check that this carrier is of this specific method, the closest thing is the delay but this can change in many prestashop stores.
There is some method, parameter or function that tells me 100% if the carrier is pick up in-store, a parameter or something that never changes in any prestashop store?

Every carrier has id_reference in database, it is something what is always same, as you might know, every time you edit Carrier in PrestaShop, a new instance is created and inserted into database, id_reference field helps you track original id of Carrier.

Related

Extend Spartacus NGRX Store with additional data

For our Spartacus project, we need to introduce additional Data properties in the checkout:
We have the case, that the user needs to select a delivery mode per product.
In an ideal world, upon selection, the selected delivery mode would be saved in the NGRX Store and also in the Backend to stay within the principle of the data binding defined here: https://sap.github.io/spartacus-docs/connecting-to-other-systems/#component-data-binding
Expected Data / User flow:
User goes to Checkout and to Delivery Mode Step
Custom OCC Call is made to load the supported delivery modes for each product (depends on product type and further customer specific logic)
The cart items are displayed, enhanced with a dropdown containing the available delivery modes
The user selects a delivery mode
The selected delivery mode is stored on the cart entry within the NGRX Store and saved in the backend
The new Cart totals is calculated based on the costs of the selected delivery mode
The new Cart totals is stored on the cart within the NGRX Store and saved in the backend
The user clicks on continue to get to the Review Order Step
The cart items are listed with the previously selected delivery mode
After some analysis of the existing code, we found a property deliveryMode on the orderEntry. This does not seem to be used anywhere in spartacus, but could be used to make Step 9 work by following this stackoverflow answer and this one.
Questions regarding this flow:
How can we extend the NGRX Store? We assume, it would be possible to just extend the facade (Active Cart Service), bypass the store and save the information in the backend (Described here) and afterwards refresh the store from the backend. Is that Assumption correct? If yes, that feels awkward though, as we need to reload the whole store just to contain the new property deliveryMode on the orderEntry
How can we hook into the price calculation of the cart totals to update the total based on the selected delivery mode? And again, how can we bring the new total sum into the store?
There seem to be several Answers within the Slack Channel without very few usable answers around extending the ngrx store, even though for us, it seems to be a quit normal task.. :-/
Any thoughts, inputs or support would be very appreciated. :-)
This seems like a difficult thing to accomplish seeing as delivery modes per product aren't supported as-is in spartacus. But some ideas:
You can extend core CartEntry classes (adapter, connecter, facade, etc.) to include the delivery mode for entries added to the cart. You will probably need to change all to include the delivery mode setting(s). All of these are exposed so you can modify them as needed including the store.
Utilizing multiple carts to have a product per cart and set delivery mode that way. But this would be cumbersome in my opinion.
As far as price calculation goes, I'm assuming OCC calls return total prices. Does the call for the cart entries include delivery mode costs per entry?
We have implemented the following work around and it works so far:
Enhance the Cart Model in the backend
Add new Endpoints to load the available delivery Modes per Product (by bypassing the NGRX Store)
Add new Endpoints to save the selected Delivery Mode (by bypassing the NGRX Store)
After Save Endpoint, a cart Reload is triggered, which loads the new cart totals having a custom property on the order entry (via type augmentation) into the store from the backend
It's already a lot of years past since Spartacus project started, but looks like it's still really raw projects. Spartacus is not ready to deal with real word customer's requirement and complexity of customize it quickly grow at real project(so you start to think do we really need it, as it's so unflexible at some dimentions). Some parts is really hard or not possible to customize, so you begin to search a workarounds(This question is one common case).
I think NGRX Store is one of the biggest pain in the ass to customize something at Spartacus. 2 years past and nothing changed by Spartacus team...

How to get a product modification log in Prestashop?

Is there a way to know what specific changes were made to a product in Prestashop 1.7?
In Advanced parameters> Logs I can see the employee who has made the modification, the severity, the message of the modification, the id of the object that has been modified and the date on which the modification was made, but it does not show me what the modification was. specific change that was made, if the name, price, description etc.
Is there a way to know that?
There is a way but it's a complex issue, you can hook into dynamic hooks like:
actionObjecProductUpdateBefore
and
actionObjectProductUpdateAfter
and compare two set of object data to see what has been changed.
Of course if you want to log more detailed informations like changes in Specific Prices etc. you also need to get informations about them before and after product change, it might be a time and resource consuming operation so be careful with it.

API for auto discount based on customer group Shoopify Plus

Hi we have a shopify plus store and we have to provide a auto discount based on the customer groipus.
Suppose a customr is in vip group he should get automatically 50 % discount.
I can see shopify don't provide this.
Can you please provide an API reference with which i can detect the customer group and apply discount on his cart.
Check out the Shopify Script Generator here https://jgodson.github.io/shopify-script-creator/
I use this for creating all our scripts and it makes it so much easier.
I currently have a script which automatically applies free delivery to all customers with a "VIP Platinum" tag from our loyalty program, you can do the same thing for discounts.
tip, don't forget to export and save the file somewhere, this way if you need to edit or add another rule to it you don't need to start from scratch again.
edit: forgot to mention, as per your requirement this doesn't apply a discount code either. you can use the generator to create another script to block discounts from being used with this if you need/want

Prestashop: Carrier Names are not translatable anymore?

In Prestashop 1.6.
I don't understand why the Carrier Name field is not translatable anymore.
I found serveral topics just saying that this was posible in older versions but no now. But why?
I have names like: "Standar Delivery" How are we supposed to translate these names?
Is there other approach to work with carriers and languages?
thanks.
There is no way to translate carrier names and there is issue (improvement) opened in PS Forge since 1.4. I think the reason behind is that carrier usually has a name, e.g. DHL which does not need to translate.
I see in merchants' stores they use store's name as carrier. e.g. if you have Shop ABC, then carrier name would have the same name - Shop ABC.
If you have more than one carrier, e.g. Priority Shipping, Standard Delivery, etc. then it won't work. My suggestion would be to use Standard Delivery and below there is a field named Transit time which is translatable. It is actually the same as description so you can add short description about each carrier in different languages. Customers won't need to know which type of delivery is offered by the carrier name, they can read description next to its name.
Also it would be good to have informational (CMS) page about delivery types and costs. I would say it is a must for an online store.
i have done this before for PrestaShop 1.6
I know it's possible but you need to modify 2 files and you need to adjust the database.

Prestashop backorders

By default my store does not allow for backorders. I want some products to be allowed. So I go at the product and change it to allow it. So far so good.
My issue is when someone backorder that product. I want the system to automatically change its status to "ON BACKORDER" (which it's not doing) and, when I have the product on stock it change it again to payment accepted.
Is that a way of doing so? If so, how?
Thanks a lot guys
EDIT
What I would like to do is this:
I want to star selling a product which will only be available 10 days from now, for instnace.
So I add it with zero stock and choose "Allow backorder"
When a client order this product and pay for it, I want their order's status to be set to BACKORDER and for then to receive an e-mail informing this
So do you want that a customer has no ability to buy products that are on backorder? Because now it works how it should be: if product is out of stock=you can't buy it, if it's on backorder=you can buy it with so called negative store level. What you're trying to achieve is probably called Waiting list and is not a default Prestashop behaviour. There are few paid extension on addons.prestashop.com for this