Add custom calculated shipping to the total on checkout in Drupal Commerce? - drupal

I want to add custom calculated shipping value (based on the origin of the shipment of the book) to the total amount of the order. I can now calculate the shipping value based on the order ID in my custom module....
I want to be able to add this value to the order total on checkout, is that possible?
I have tried shipment rules, but it is not satisfactory as it only allows me to add a value to the line items in the order and not to total. How can I hook to the checkout process and add this amount to the total? Maybe I can add it as custom line items on checkout?
Also, since it is a custom shipment method with customs shipment companies, do I need to use any of the shipment modules in the first place ( I neither use flat service or any of the commerce shipment modules) ?

Try API of respective commerce/ubercart module. They must offer some API which allows you to modify the check out page

Related

Drupal 8: Only add to cart if user has enough credits

I've a site where transactions are based purely on credits. No actual money is exchanged. In such a case, I want to restrict users from adding products to cart if they do not have credits to do so.
In steps of how this should be accomplished, here is the sequence of events which I think should work :
Whenever somebody tries to add a product :
Use Rule "Before adding product to cart"
I need to get the value of the following :
Get user credits
Get sum of current product + cart value
Check for condition if credits is greater than product + cart.
If true, add product to cart else display "Not enough credits".
I use the loyalty points module for the user credits.
How can I set up the rules for this scenario?
Instead of using a module I just used a custom_validation function on commerce_add_to_card_form as suggested by lamp5

How to set custom order total in woocommerce?

I currently have 6 items in cart, which cost £456. I'm trying to implement a custom payment system, so the customer can pay some now and some later. So i want the cost to be £400.
The only function i've found is set_total in WC_Abstract_Order but to use WC_Abstract Order you need the order id and the order hasn't been placed yet for an id to be generated.
Any idea how to solve?

Custom loop for getting products flagged as new

I was looking for a way to build a custom loop to get the products flagged with the "new" label.
I could use the sort from the insert time, but that would always include a certain number of products, my goal here is to get those products that conform to the WooCommerce setting that says the product is considered new for a given number of days.
i have a free plugin - WooCommerce Product Badge, it has your requested feature to display "New" label with certain days defined.

Drupal Commerce Products for printing company

I'm new to Commerce I hope some kind fellow could give me some directions here.
I am creating an ecommerce website for a printing company. I will give an example of what I require
For instance they will offer A6 flyers but these come in different specifications each with differing prices
Here is an example:
http://4frontdesigns.co.uk/Untitled-1.jpg
So down the left column are quantities of flyers and along thw top different speciifications of those flyers with the prices shown in the middle.
Any help much appreciated
Can I just add each variation of these one by one as it is not possible to just say that a certain additional attribute to the product will add so much $$ to the base price.
Would I just add each variation one by one then some how pull these all into one display?
You could use the commerce price table module like Flo suggested or look at the Price attributes Module https://www.drupal.org/project/commerce_pricing_attributes
It uses option sets and then add to (or subtract from) the price based on the selected attribute.
The answer for me was to create each product variation as its own product. So every variation gets added as a separate product.
If you are wondering how to add different variations to product such as paper size or colour, you would do this with taxonomy. Simply create a taxonomy term called colour and then add all the colours into this term that you would require.
Then when you create your product type in commerce, you would add this as an option to choose from when adding products by doing the following. Go to manange fields for the product type you want to add it for and add a new field, type of data = term reference. You will then select the desired taxonomy term and also there will be an option to 'Enable this field to function as an attribute field on Add to Cart forms.' - You want to select this!
Then what you do is create a product display and pull all these in to a single page, which then gives you drop down options to change, and the price changes accordingly in real time.
You can create a product display by creating a new content type first, call it product display... Then add a field to this content type which is a 'product reference'.
Now add new content, pick to create a product display (what we have just created) and choose the products that you want to appear on that page.
Then automatically Drupal Commerce will take care of the rest. Hope this helps someone!

Drupal VIEWS Price Filter

I have a VIEWS page set up to display various products and would like to be able to filter them by price range. I've read that "Contextual Filters" is the right way to go about this but when I add a filter, the field (price) isn't listed.
Your filter doesn't need to be a contextual filter (those are used to fetch a parameter from e.g the url of your page). If you just need to filter your products by price just set a regular filter on the price field. If you want to define a range, set two filters : price > min and price < max. If you need to expose it to users, you have to set ajax on (advanced section), and you can use Better Exposed Filter to get a nice slider (with jQuery Slider).

Resources