Packaging Costs - shopping-cart

I would like to add to any order a service product similar to the row for shipment costs that gives information about the packaging costs.
Could anyone give me some hints which steps are required in order to implement the described goal. Thank you in advance.

OPTION 1
The best way would be to create a 'free text field' (Configuration -> Free Text Field Management) and then modify the SQL Query in the Storefrontsettings (Configuration -> Basic Settings -> Frontend -> Shipping Costs Modules).
It depends now how you want to vary it or if the packaging costs are the same. Though I believe you probably want to make them depend on the size of the product.
So you could something like that:
//You put this code in the Shipping Costs Modules
MAX(a.topseller) AS has_topseller, MAX(at.attr3) AS has_comment
MAX(b.esdarticle) AS has_esd,
SUM(at.attr4*b.quantity)
The important part here is the last line of code.
To make this work you have to create a 'free text field' called attr4 and now in the article details in the backend (Items -> Overview -> Pen Symbol) you put in your wished value for the article.
However this example is very specific because you have to do it for each and every article but the method stays the same for almost every case.
Add new Free Text Field
Edit the Value for it in the Article Details
Modify the SQL in 'Shipping Costs Modules'
If you understand german you can also checkout there documentation for that topic here.
OPTION 2
In Option 1 the price gets just added to the normal shipping costs. Though if you want them to be displayed seperately, the only way I can think of is to create a little Plugin.
To start off with Option 2 you have to create a free text field though.
After you created it go to checkout -> cart_footer.tpl
There you add your newly added free text field between the shipping costs and the total sum like this:
{block name='frontend_checkout_cart_footer_field_labels_shipping'}{/block}
{block name='frontend_checkout_cart_footer_field_labels_package}
{block name='frontend_checkout_cart_footer_field_labels_package_label'}
<div class="entry--label block">
Packaging Costs
</div>
{/block}
{block name='frontend_checkout_cart_footer_field_labels_package_label'}
<div class="entry--label block">
{s name="CartFooterLabelPackage"}{/s}
</div>
{/block}
{/block}
{block name='frontend_checkout_cart_footer_field_labels_total'}{/block}
This is basically just for the customer to see the price he pays for the packaging.
Now it is time for the plugin creation.
All you basically have to do is to create a local plugin, that submits some easy SQL queries.
You create the basic plugin structure like shown here
Then you modify it that on the checkout/finish controller you manipulate the invoice_amount:
public function addPackage()
{
$package = 2.5;
$select = "SELECT invoice_amount FROM s_attribute_configuration ORDER BY id DESC LIMIT 1";
$select_result = Shopware()->Container()->get('models')->getConnection()->fetchColumn($select);
$new_price = $select_result + $package;
$update = "UPDATE s_attribute_configuration SET invoice_amount = $new_price ORDER BY id DESC LIMIT 1"
$update_result = Shopware()->Db()->query($update);
}
Something like that should do it. Just hook that into the finish-action.
The last problem you would have now is that the total sum gets updated already in the frontend. I think you could update that with some Javascript.
OPTION 1.1
Just got this idea while creating the PHP-Script for Option 2:
Just add the packaging to the shipping costs like in OPTION 1 and then add a little info under the shipping costs that the packaging costs of (insert packaging sum here) are included there. You could do that with free text fields, too. Would be the best easiest solution that would get you almost perfectly to your wished result.
I hope any of these help.

Related

Kibana: can I store "Time" as a variable and run a consecutive search?

I want to automate a few search in one, here are the steps:
Search in Kibana for this ID:"b2c729b5-6440-4829-8562-abd81991e2a0" which will return me a bunch of logs. Of these logs I need to take the first and the last timestamp:
I now would like to store these two data FROM: September 3rd 2019, 21:28:22.155, TO: September 3rd 2019, 21:28:23.524 in 2 variables
Run a second search in Kibana for the word "fail" in between these two variable of time
How to automate the whole process without need of copy/paste and running a second query?
EDIT:
SHORT STORY LONG: I work in a company that produce a software for autonomous vehicles.
SCENARIO: A booking is rejected and we need to understand why.
WHERE IS THE PROBLE: I need to monitor just a few seconds of logs on 3 different machines. Each log is completely separated, there is no relation between the logs so I cannot write a query in discover, I need to run 3 separated queries.
EXAMPLE:
A booking was rejected, so I open Chrome and I search on "elk-prod.myhost.com" for the BookingID:"b2c729b5-6440-4829-8562-abd81991e2a0" and I have a dozen of logs returned during a range of 2 seconds (FROM: September 3rd 2019, 21:28:22.155, TO: September 3rd 2019, 21:28:23.524).
Now I need to know what was happening on the car so I open a new Chrome tab and I search on "elk-prod.myhost.com" for the CarID: "Tesla-45-OU" on the time range FROM: September 3rd 2019, 21:28:22.155, TO: September 3rd 2019, 21:28:23.524
Now I need to know why the server which calculate the matching rejected the booking so I open a new Chrome tab and I search for the word CalculationMatrix always on the time range FROM: September 3rd 2019, 21:28:22.155, TO: September 3rd 2019, 21:28:23.524
CONCLUSION: I want to stop to keep opening Chrome tabs by hand and automate the whole thing. I have no idea around what time the book was made so I first need to search for the BookingID "b2c729b5-6440-4829-8562-abd81991e2a0", then store the timestamp of first and last log and run a second and third query based on those timestamps.
There is no relation between the 3 logs I search so there is no way to filter from the Discover, I need to automate 3 different query.
Here is how I would do it. First of all, from what I understand, you have three different indexes:
one for "bookings"
one for "cars"
one for "matchings"
First, in Discover, I would create three Saved Searches, one per index pattern. Then in Visualize, I would create a Vertical bar chart on the bookings saved search (Bucket X-Axis by date_histogram on the timestamp field, leave the rest as is). You'll get a nice histogram of all your booking events bucketed by time.
Finally, I would create a dashboard and add the vertical bar chart + those three saved searches inside it.
When done, the way I would search according to the process you've described above is as follows:
Search for the booking ID b2c729b5-6440-4829-8562-abd81991e2a0 in the top filter bar. In the bar chart histogram (bookings), you will see all documents related to the selected booking. On that chart, you can select the exact period from when the very first booking document happened to the very last. This will adapt the main time picker at the top and the start/end time will be "remembered" by Kibana
Remove the booking ID from the top filter (since we now know the time range and Kibana stores it). Search for Tesla-45-OU in the top filter bar. The bar histogram + the booking saved search + the matchings saved search will be empty, but you'll have data inside the second list, the one for cars. Find whatever you need to find in there and go to the next step.
Remove the car ID from the top filter and search for ComputationMatrix. Now the third saved search is going to show you whatever documents you need to see within that time range.
I'm lacking realistic data to try this out, but I definitely think this is possible as I've laid out above, probably with some adaptations.
Kibana does work like this (any order is ok):
Select time filter: https://www.elastic.co/guide/en/kibana/current/set-time-filter.html
Add additional criteria for search like for example field s is b2c729b5-6440-4829-8562-abd81991e2a0.
Add aditional criteria for search like for example field x is Fail.
Additionaly you can view surrounding documents https://www.elastic.co/guide/en/kibana/current/document-context.html#document-context
This is how Kibana works.
You can prepare some filters beforehands, save them and then use them if you want to automate the process of discovering somehow.
You can do that in Discover tab in Kibana using New/Save/Open options.
Edit:
I do not think you can achieve what you need in Kibana. As I mentioned earlier one option is to change the data that is comming to Elasticsearch so you can search for it via discover in Kibana. Another option could be builiding for example Java application, that is using Elasticsearch - then you can write algorithm that returns the data that you want. But i think it's a big overhead and I recommend checking the data first.
Edit: To clarify - you can create external Java let's say SpringBoot application that uses Elasticsearch - all the data that you need is inside it.
But in this option you will not use Kibana at all.
You can export the result to csv or what you want in the code.
SpringBoot application can ask ElasticSearch for whatever it needs, then it would be easy to store these time variables inside of Java code.
EDIT: After OP edited question to change it dramatically:
#FrancescoMantovani Well the edited version is very different from where you first posted here How to automate the whole process without need of copy/paste and running a second query? and search for word fail in a single shot. In accepted answer you are still using a three filters one at a time so it is not one search, but three.
What's more if you would use one index, and send data from multiple hosts via filebeat you don't even to have to create this dashboard to do that. Then you can you can select the exact period from when the very first document happened to the very last regarding filter and then remove it and add another filter that you need - it's simple as that. Before you were writing about one query,
How to automate the whole process without need of copy/paste and
running a second query?
not three. And you don't need to open new tab in Chrome each time you want to change filter just organize the data by for example using filebeat as mentioned before.
There is no relation between the 3 logs
From what you wrote the realation exist and it is time.
If the data is in for example three diferent indicies (cause documents don't have much similiar data) you can do it like that:
You change them easily in dicover see:
You can go to discover select index 1 search, select time range that you need, when you change index the time range is still the one you selected, you only need to change filter - you will get what you need.

Opencart, Flat Charge for option (not related to Quantity)

I am having trouble with my order processing for Opencart 1.5.6. I have a series of checkboxes that if checked each cost $50.00. The problem is that the customer is ordering print materials in quantities of 500, 1000, 5000, etc. When they get to the shopping cart it charges the $50 extra for each option for each individual item ordered based on the quantity. This makes it so that their total skyrockets. If they pick one option for $50 and order 500 business cards they get charged an extra $25,000 for that one option.
The only solution that I can see is to have the Quantity be an option and only allow them to order one product but that does not allow them to change the Quantity of cards in the Cart.
Is there anyway to set it up so that an option charges a flat rate not based on total quantity of the order?
When customizing OpenCart follow these steps.
Look to see if this link has an extension that will do what you want.
If step 1 did not work. Go to your public_html file (the place that has all your code). Open the files that are related to your problem and edit those. There is also an OpenCart forum that will help with common problems.
As far as changing the settings on your payment function. Go look at OpenCart->catalog->checkout folder. Or maybe OpenCart->admin->checkout. You will need to find the function that adds quantity and gives value. You will need to change those around a little.

how to add "product filter by price " in opencart

i am trying to add product filter by price in opencart, So how to do this?
also add this featured in product page
Follow this steps you can easily add the Price filter for your open cart front end page
Filter I Category → Filter-->Insert--> add filter.
Give--> 1000,2000 and more.
Now Save Filters.
Filter II Extension-->Modules-->Click Filter.
Maintain with Column Left
Status enabled.
Filter III Catalog -->Products-->Click Edit
Go to Links-->Type Filter Amount
If Product Price 2500 ,then maintain the filter value price (2000 – 3000) Range.
Regards
Megala
In fact, it is unnecessary to add the price filter. It is possible to generate the price range filter automatically for products listing when the customer access any category in your store.
I use an advanced products filters module(include price range filter) for my store > http://www.myluvme.com/index.php?route=product/category&path=88_95.
It really help my customers focus in on what they are looking for which will create more sales.
The mod worked out of the box with the default theme and only needed some minor tweaks to work with my custom theme which the developer did for me immediately. i like that it builds upon the framework of oc.
It should be useful to boost your online sales too. I recommend you to try it. You could find it at:
http://www.ocaddons.com/product/opencart-module-advanced-products-filters-module-include-price-range
Unlike many other shopping carts there is no a built-in filter in OpenCart that could be considered a normal usable e-commerce store filter unfortunately. The OpenCart filters thing is a super clumsy functionality and it's not very clear for users how to administer it. In our company we use an extension called Brainy Filter http://www.opencart.com/index.php?route=extension/extension/info&extension_id=19184 They have it for both OpenCart versions but of course you should go with 2.x rather then the old 1.5.x one. All other filters we tried appeared to be either just junk or had very messy interfaces.

webservice for autosuggest on city names / postal codes including long-lat coordinates?

i'm looking for a webservice, to be used for an autocomplete field,
where people can fill in either a postal code / city name or both
this service will need all cities in Europe, so we can use it for all country websites.
and in a later stadium we want to keep the world open for asia and america so this would be a plus.
preferably it would also return the long-lat coordinates for the locations,
Now it is a free textfield, after leaving the field, we hit the google geocoding service,
to find coordinates... preferably i would tie these two together.
so we don't have to query 2 services for one thing.
does anyone know of the existance of such a service online somewhere?
or would you suggest to build our own database with cities / postal codes / coordinates?
if so we would need to get the content from somewhere too, and i was trying to avoid that issue :)
I recently searched for a similar service, in vain.
I wanted my users to have auto-complete on entering a city name, and once a city is chosen I needed to pass the name and lat/long onto the Google API. In the end I did this: -
downloaded the geonames allcountries.zip, full extract: this
Imported it into a SQL DB via SSIS (about 7.5 million records!)
Wrote a simple query to extract just the cities (only the PPLC, PPLA and PPLA2 records).
This left me with a manageable table of 9112 records (with lat / long and country code) which covers all the cities in the world. I then wrote my own code to query the data.
Not ideal, but I needed a solution.
I know this post is very old but for thouse who are looking for a simple solution that can be integrated in 5 minutes here is the link:
Geocomplete jQuery...
For my case I followed this steps:
1 - Download the plugin from here.
2 - Add the jquery.geocomplete.js or jquery.geocomplete.min.js file into your javascript folder of your project.
3 - Call this file in script tags on the html page where you have the input field that you have to autocomplete with cities:
<script src='/PathToTheFile/jquery.geocomplete.js'></script>
4 - To convert an input into an autocomplete field, simply call the Geocomplete plugin in script tags: <script>
$("#IdOfTheInputField").geocomplete(); // Option 1: Call on element.
$.fn.geocomplete("input"); // Option 2: Pass element as argument.
</script>
5- You can check for the complete list of options on the link provided at the top.
Hope that this helped!

Order totals block on Magento order email and invoice email templates

Can anyone point me to the templates/code blocks that are used for the order totals block on the Magento order mail and invoice e-mail templates?
The tax issue is solved but I need to implement some logic to get rid of the shipping and the subtotal. Which templates are used for the emails?
I found the frontend and changed this as needed, but can't find the template/block that is used for the e-mails sent by the system.
Can anyone point me in the right direction?
Thanks,
Bart
Niels answer of app/design/frontend/base/default/template/sales/order/totals.phtml is correct however I thought some further clarification was in order because one doesn't merely make cosmetic changes to this file in order to effect the desired change. totals.phtml loops over the "totals", each of which produces a total-related line-item (Subtotal, Shipping & Handling, Tax, Grand Total (Excl. Tax), and Grand Total (Incl. Tax)). Your best bet is to use Mage::Log to output each of the totals (which are looped over via an associative array $_code => $total). If you log each key ($_code), you'll see names such as subtotal, shipping, grand_total, tax, and grand_total_incl. I filtered out those from the sales order e-mail that I didn't want by adding the following code directly below the foreach:
<?php if (in_array($_code, array('grand_total'))) {
continue;
} ?>
Hopefully this will help anybody who is puzzling over where these totals are mysteriously coming from. :-)
This template is being used for the totals in the e-mail templates and order overview in My Account:
app/design/frontend/base/default/template/sales/order/totals.phtml
Jason's answer is good for telling Magento to not generate the likes of grand_total HTML. However, you should look at System > Configuration > Sales > Tax to see if you can remove the fields the proper way first.
If you then see a message saying "Warning tax configuration can result in rounding errors" at the top of your admin pages, you'll need to adjust your settings. See the manual for the default settings, if you need them.
I am not entirely sure but could it be this one:
\app\design\adminhtml\default\default\template\email\order\items.phtml
Directory might not exactly match yours but I'm sure you would be able to find it.
HTH