Custom shipping method admin form issues - orocommerce

I've created a custom shipping integration (based on this guide) that calculates the shipping price based on a percentage of the subtotal. This percentage is set in the shipping method settings.
Everything works fine on the frontend part, the shipping price is calculated correctly.
The problems I have lies in the admin backoffice, in the shipping method settings page. The first problem that I have is that the text box to set the percentage is preceded by the currency, which will confuse the user as it is expecting not a flat rate price, but a percentage of the order's subtotal.
I have the same problem on the list of added shipping methods, the value I set is preceded by the currency, and this is not good.
There is a "add a template" section in the guide which I followed, but the template doesn't seem to affect anything. I tried putting bogus letters in the template and clearing the cache, but they did not appear anywhere on the settings page.
What I would like to do here is either remove the currency indicator completely, or to replace it with a %.
The second problem I have is that the language isn't taken into account. I have created a messages.en.yml file and a messages.fr.yml file. Both follow the same structure of course, and all strings are translated. But if I set OroCommerce in French, I don't get my translated strings, but the english ones.
Here's a screenshot that shows both my problems :
(Strings like "Price percentage" should be translated)
Do you have an idea on how I could fix these issues? Thanks.

Currency is added in shipping-rule-method-view.js. You can override this JS view with the map section in jsmodules.yml configuration file.

Based on Andrey's answer, I managed to have something that works. I'll add a few more details for anyone that had the same issue.
For the issue with the translation, it seems that renaming the file by adding the locale messages.fr_FR.yml fixed the issue.
Concerning the currency part on the admin menu, you have to create a jsmodules.yml file in the Resources/config folder of your bundle, NOT Resources/config/oro, which is why none of my configs were taken into account.
When writing your jsmodules file, when using map, if you're overriding a JS file, you have to omit the file extension. When you're overriding something else, say an HTML file, you have to put the file extension.
This is how my file is written :
map:
"*":
oroshipping/js/app/views/shipping-rule-method-view: gdmshipping/js/shipping-rule-method-view
There is one caveat, though. This will replace the display for all shipping integrations, so the currency symbol will be replaced/removed for all other shipping types, such as Flat Rate, so keep this in mind.

Related

Outputting Shopify product metafields as HTML

I'm working on a custom code block for the Tapcart app version of my e-commerce site on Shopify. They have the ability to add HTML, CSS and/or JS in a custom code block.
However, I cannot get the html to output the custom fragrance notes (my custom metafield) for the product. Matter of fact, I can't get anything to output- it's just blank.
Thoughts? Appreciate your help!
{{product.metafields.custom.fragrance_notes}}
I tried {{product.metafields.custom.fragrance_notes}} expecting it to output the plain text multi-line of each individual product's fragrance notes (which I have as a custom metafield for each product) but instead nothing displays at all.
When asking for metafield data you can often meet with success by asking for the value stored at that key.
{{product.metafields.custom.fragrance_notes.value}}
Since the namespace is custom, the key is fragrence_notes and what you want to use or display is the value. So it is a key:value thing.
Of course, if your metafield is empty, you won't see anything no matter what.

Shopify - is it possible to change the preview of a product with a inputbox?

Which ways are possible to edit the live preview of the product page in Shopify with Inputboxes next to it?
Let's say the product is a poster, and i want to add a custom text on it.
When typing into the inputbox the text changes in real time on the product.
Can this be implemented in the shopify code with the basic version of shopify?
Or does this necessarily needs an app?
ADDITIONALLY:
Let me go a bit deeper. I have a code that can generate a QR code.
Now i want that the QR code to be previewed in the product. Now position and color of the QR code is different from any product. Would that need an app?
Yes you can to an extent.
First the ground rules:
You can't modify the product from the front-end and update the content or media in the back-end - this would be a huge security hole
The changes applied to the product will be visible only to the user who changed them
The solution is to use Javascript and update the content of the front-end. If you like to store the changes for that specific user you can save them as cookie or localstorage.
If you like to share this change to other people you will need to add a custom parameter in the URL of the page and generate the content from it and share that url.
Each one of these steps will require some custom Javascript that will affect only the user in question, if you like to modify the product in the back-end directly you will need some kind of an app for this.
On my mind it can be done if the dynamic text is applied over product image.
Detailed code would be too long to write here but here are the steps:
Add an input to your product form to add a custom property (https://community.shopify.com/c/Shopify-Design/Product-pages-Get-customization-information-for-products/td-p/616503)
Write a Javascript function to get input value in real time
Use this value to display it in a div in product image container
Position this div in CSS as absolute and style it as you wish
While image container position should be set as relative in CSS
HTH

How to change in template through the Shopify application

I am trying to write a Shopify application and I want to add a section to the product page when the store owner installed my app. I tried this by adding a custom script tag in the shop template and this tag will load and inject my desired HTML into the page. It's work but it needs to force the store owner to change the product page template and its not user-friendly.
I see some apps in the Shopify app store that can change the product page after you install them without needs add any part to the product page template. How they do this work? I can't find the correct way in the Shopify documents.
You can change the Shopify theme of the shop using The API for Assets:
However as drip mentioned this is not a good idea:
If you change the theme auto-magically via code, you are looking for trouble. A lot of things can go wrong - simply you cannot cater for all themes and their changes over time! So you could possibly leave a broken page after the change. The e-shop owner won't be impressed! Actually a lot of the 1* reviews of apps are for that reason!
What would happen if the eshop owner removes your app? He won't know what code to remove.
So, most apps ask the user to add the app code. They provide detailed instructions of course.
Fyi, another problematic approach is the following:
Some apps may attempt to change the DOM "on the fly", by first locating an existing DOM element (a lot of theme-specific if statements to do that with any degree of success) and, then insert the app's DOM elements.
That's very messy and problematic as well, but at least you do not risk ruining the owner's theme files. In the worst case he can uninstall your app and he 'll be ok.

How can be changed a documenttype layout in Hippo CMS

I created a hippo documenttype using a one column layout. For rendering purposes I would like to reorganize the given items into a two-columns layout.
However, no option is available to do this change, at least not by using the latest hippo cms community version.
I have already searched in google and found following information, saying that it may be possible to change the layout by using the console, but no information about how:
http://hippo.2275632.n2.nabble.com/How-to-delete-or-rename-document-types-td7579269.html
I would appreciate any hints about it.
AFAIK there is no documentation on how to do this: this is not very complicated but this is a tedious process. If you still can - for instance your document type is not used yet - I would advise to simply drop it and recreate the content type. That being said, here is how it works:
look into your project namespace in the console: the path is something like this: /hippo:namespaces/YOURPROJECT/document-type/editor:templates/_default_/root
the root nodes defines the layout. Check out the plugin.class: for a one column this will be org.hippoecm.frontend.service.render.ListViewPlugin and for a 2 column layout the plugin.class will be org.hippoecm.frontend.editor.layout.TwoColumn
for every field in your document type (that's the tedious part) you will need to define if the field placed on the right or the left.
this is configured on the node with the name of the field path, as a property wicket.id that for instance have the value ${cluster.id}.left.item. This means the item will be placed on the left side.
Your best bet is to create a 2 column example document type and look carefully at its configuration and replicate the changes in your existing field.
Have you tried the instructions on the link below ?
http://www.onehippo.org/library/concepts/document-types/custom-editor-layout.html

Magento: Special Price not Visible in Product Information

I am using Magento 1.6.1.0 and would like to use the special_price attribute (which is enabled for 'All Product Types'). Like so:
However the special price field, which I have seen visible on countless screen shots from other systems, is not visible. Here's a screen shot of my 'prices' tab in the product information editor:
What have I missed here? As you can see from the screen shot, the Tier Price is showing (and working) completely fine. Do I need to enable the special price attribute elsewhere?
I had the same issue, I found a fix that worked for me. Under the attributes list, I searched "price" found an existing "special price" attribute. I had to edit the "apply to" section to in my case "all product types" but would also work for any particular product type. Hope this helps someone else.
so, as i see you have attribute value set as required, but i dont see any red asterisk symbol (*) near to it. and actually i dont see on screenshot Special Price field either??
so all you need is:
create attribute.
name it Special Price with code special_price.
set to Display on product page.
Add it to your Attribute Set.
edit product and enter Special Price value.
then call it on product view.
there is no magic. i dont see what you have done exactly. But it looks like you did something wrong.
ps. by the way isnt it default Magento feature?? Special Price with dates From/To??
have you modified your core features somehow??