Drupal Commerce Set Order Total Rules - drupal-7

I have Tried to Recalculate Order Total Using the rules which is not happening
Here is what i did
Rules Event - Calculating the sell price of a product
Rules Action - Set Data value
on this action i setted the updated price to the commerce order
(Ex)
the original price - 16
the updated price - 15.20
Rules Action - show message on site (Which shows the updated commerce order for testing)
Here is what i get
The Order of the price displaying on site from show message on site action is
15.20
16.00
which means the updated 15.20 is overwritten by the old price 16.00
I don't no from where the overriding happens

Order Total can changed through line items
Commerce line items modules have rules action "Multiply the unit price by some amount"
You need used this action.
set the value of Amount 0.95 (16.00 x 0.95 = 15.20)
Set the value of PRICE COMPONENT TYPE "Discount"

Related

Apex/Salesforce/flow: Be able to increase price and clone/update product automatically

I asked a similar question before but I am still struggling and was not able to do what I was required to do and am coming back to this community for help.
I am trying to increase the price of the products on a quote in salesforce CPQ/Billing based on a field and to do this automatically.
The Setup
In Salesforce CPQ, If you go to account -> Contract -> Sales Service: There is a field called Price Increase %(PROD_Price_Increase__c)
A contract can have multiple quotes
What I want to do
When a quote has reached the final step a contract is created. In the contract I have the option to click a button called Amend. Which allows me to take the products in the existing quotes and amend it.
I want to create a batch job that does the following:
The Contract has these fields: Start Date (PROD_Start_Date__c), Price increase Date (PROD_Increase_Date__c), End Date (PROD_End_Date__c).
-- If the Price Increase Date is 12 months after the start date, these are the contracts that will need to be updated
-- For example, If the start date is 15 Feb 2023, Price increase is 1 Jan 2024, end date is 15 Feb 2025. Since the increase date is not 12 months, these contract should be ignored.
Main Task
When products who have a price increase 12 months after the start date, the contract should be able to 'amend' and update the quantity of the products and clone the products.
In the contract, the action buttons on top have "Amend". once clicked, it shows all the subscriptions products, you click next then it comes into the edit quote page.
Once here it shows all the products that were part of the contract and its quote. The net price filed for the original products will be '0'. These products will need to be cloned and the quantity for these to be applied to the cloned products. Once the quantity has been copied over, the original products quantity should change to 0.
After these products have a quantity of 0, the clone products should have the price increase. The value I mentioned from earlier Price Increase % (ROD_Price_Increase__c) value should be added to the Discount filed in the quote but as a minus value since we are doing an increase of price.
Once this has been done, we can submit/order the quote. This creates a new quote. Once the new quote has been created, I want to be able to update a filed in the quote - a checkbox that says order. I want to be able to check the value on it.
This all should be done automatically like though Apex and Flows.
Sorry for this long text and request. I apologise and know some of the information not be out of box or confusing. Its one of these challenges I have been facing with trying to automate this.

How can I update or change cost price (standard price) in odoo v13 postgresql database?

I am trying to change the cost price of products in Odoov13 in postgresql database, can anyone please support me with an example or guide? The question is simple, there is a selling price and a cost price (standard price) on the products, I just try to change the cost price, not the selling price, but I don't know how to get to the table or column, the Only reference I have is that the value can be stored in property field, but I don't know how to access it.
SELECT * FROM ir_property WHERE name = 'standard_price';
Fini
The field standard_price is computed field without store=True So it can store the data into postgres database.
If you want to update the field value, You can make the server-action following step:
Goto Settings->Server Actions
Model : Product Template
Action To Do: Update the Record
Data to Write:
Field : Cost (product.template)
Evaluation Type: Value
Value: Add your value example, 112
make the Create Contextual Action
Goto Product template and refresh the page on the action you can find the created server action and execute.

Bittrex api market change calculation

Does anyone know how Bittrex calculates the market change (shown in the image) and which values i can use to replicate it
Using the "Last Price" from https://api.bittrex.com/api/v1.1/public/getmarketsummary?market=btc-fsn gives me a different value
It looks that "PrevDay" field in API response reflects the price exactly 24 hours ago. Same for some other exchanges and data providers.
Actually % change on website should be based on same, but this may depend on how often data is refreshed in browser.
This percentage sign shows how much % market has been chnaged in last 24 hours
Like prev btc price=8000 and new btc price =8500
so market change 8500-8000=(500/8000)*100=6.25%

Filtering data in a custom metric?

On a particular type of page, I have an event that fires every time someone enrolls in a product. The event is:
Category: Enroll
Action: < Name of Product >
Label: enroll
I am able to create a report that lists the number of times the event was fired on Pages by using the metric of total events and filtering by the label enroll This gives the page that it was fired on and the count of the event.
I'm now trying to do conversion rate. So, I'd want to get
(Total Events on the page (filtered by Event Label="enroll")) / Unique Pageviews
I can't figure out how to do the total events filtered in Data Studio using a calculated metric. Is there a good way to do this?
Try using REGEXP_MATCH in the sum of a case statement to achieve what you need.
Creating a metrics as follows and then do the division by unique pageviews as a second metric.
SUM(case when REGEXP_MATCH(Event Label, "enroll") then 1 else 0 end)

Apex trigger to default field values when adding opportunity line

I'm not a developer, but I'm attempting to learn since I've reached a point where I need code to customize and automate further. I've created a custom "Sales Price" field for Opportunity Products that I am using to replace the standard Sales Price field. I want the custom field to default with the price book entry list price (unitprice) value as does the standard Sales Price field. Then I have the standard Sales Price field getting updated to equal the custom Sales Price times the number of month terms (custom field that will be updated at Opportunity level and automatically populated in reflective custom field on Opportunity Products via trigger). I've created triggers for both the Sales Price value to default and the Month Terms to default, but neither seems to be working now. Below is the trigger for the Sales Price value when creating a new opportunity line item. Not sure how to get the price to default when adding a new product line item? It should only default when adding new since I don't want it to override any amount that they put in and save. But it also needs to work if they go back into the opp and add additional items later. Any input on this is greatly appreciated. I've spent hours searching posts and other documentation, but I don't have that natural developer brain, and I'm banging my head!
trigger SalesPricecustom on OpportunityLineItem (before insert) {
Set<Id> pbeIds = new Set<Id>();
for (OpportunityLineItem oli : Trigger.new)
pbeIds.add(oli.pricebookentryid);
Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>(
[select UnitPrice from pricebookentry
where id in :pbeIds]);
for (OpportunityLineItem oli :trigger.new){
if(pricebookentry.unitprice <> null && oli.sales_price__c == null){
oli.sales_price__c = entries.get(oli.pricebookEntryId).UnitPrice;
}
}}
Thanks!
Could you describe your problem in other words? If you want to recalculate sales price field when old data is updated (not only inserted new lines), you should used "before update" event for this trigger, as here:
trigger SalesPricecustom on OpportunityLineItem (before insert, before update){
//Here is your code
}
Also, you can check, which fields was changed, it will help you not to execute once again trigger logic, if other fields have been updated(use for this trigger context variables - Trigger.new, Trigger.old, Trigger.newMap, Trigger.oldMap).

Resources