I just want to add a <label> to the checkout page - magento

I just want to add a label that says "*Residential Addresses May Incur Additional Charges" somewhere in the shipping methods portion of onepage checkout.
I can't find where any of it is stored, my only clue is getChildHtml('additional'), which seems to be where it's all generated from.
I need to add this until I can figure out how to put a residential checkbox on the address page for fedex/ups quotes.
Anyone have any idea, because this should really be simple, but it's incredibly complicated
I mean I'm thinking of just making a jQuery block that'll append the label somewhere on pageload since I can't seem to find where this html is stored :/

I finally figured it out, even though it's not ideal...
in the shipping_method.phtml file, you need to find this line of code:<div id="onepage-checkout-shipping-method-additional-load">
<?php echo $this->getChildHtml('additional') ?>
</div>
Then you can insert a or whatever before it and it will show up beneath everything.
Why must they make this so hard...

Related

Magento content management; prevent a mess

So, I started on a new project this week and of course I'm thinking about the problems I'm going to find during the whole development process. We are going to make a shop that has a pretty good design, pretty excited to work on this. However, the design uses a lot of content that can't be placed in the normal functions of magento. For example there is a catalog page that has a lot of content blocks with secondary information like unique selling points or a bit of story telling. This can and will be different for different categories. We are talking about a lot of small content blocks, not something you can cram into the category description field ;)
Until now I mostly used static blocks to make this content and show them on the pages, maybe even use xpath to extract the information I need from the blocks to prevent the end-user from destroying the design by using the WYSIWYG editor. However, I don't think this will be a good solution now because there will simply be to much static blocks to create and use without loosing the overview of everything, plus I doubt xpath is really good performance wise (something like getting a screw in with a hammer).
I was thinking about making a module or using a module that makes it possible to add attributes and use attribute sets in combination with static blocks. With that you can make your own fields and groups for certain pages and make it easy for the end-user to edit information on their webshop. However, making this myself (does sound like a lot of fun) will take to much time, and I can't really find a module that does something like this.
How do you guys solve these problems when creating a new webshop? Any tips?
I suppose you will be using your own theme with own template for the category page, here you will setup all the HTML that you don't want the admin to mess up with the WYSIWYG editor and let them change only certain parts of the page. For the admin to be able to edit these, you will need to add new attributes to the category entity. For example if the admin should add text for a certain box, add text type of attribute, if the admin wants to add HTML create WYSIWYG editor type of attribute and so on. Then in your template you will check if the category has any of these attributes and they have non-empty values then print them.
For example:
<?php if ($category->getCustomTextAttribute() != ''): ?>
<div id="your-div">
<?php echo $category->getCustomTextAttribute(); ?>
</div>
<?php endif; ?>
<?php if ($category->getPromotionHtml() != ''): ?>
<div id="promotion-div">
<?php echo $category->getPromotionHtml(); ?>
</div>
<?php endif; ?>
This goes the same for the product pages with the difference that for products you can create the attributes via the admin and then print them on the product page template, otherwise for Categories you need to write a module that does this, if you want me I can provide you with an example of module for creating Category attributes.
I ended up using a combination of zokibtmkd answer and adding fields to the default static blocks (a image upload function and a link field). The combination of these two solutions gave me enough to work with in the design without messing up the admin or the templates.

How do I add additional info next to the product price in magento?

Im trying to add pm2 (per meter squared) next to the price on the product page in magento, here is an example:
after looking at the souce code for how they showed this it was:
<span class="metres">m<sup>2</sup>
so I added that little bit of code to my theme template in magento file location (app/design/frontend/default/THEMENAME/template/catalog/product/view/price.phtml):
<div class="price-box" id="product_price">
<p class="old-price"><?php echo $this->__('Old Price:') ?><?php echo $this->getPrice() ?></p>
<p class="special-price"><?php echo $this->getPrice() ?><span class="metres">m<sup>2</sup></p>
</div>
but nothing shows up, see example:
any ideas on how to achieve this ?
As an alternative approach you could try the :afer pseudo element (see http://css-tricks.com/almanac/selectors/a/after-and-before/). I don't like modifying core files (even if you do take a copy in your theme like you have) because a future upgrade may change the file significantly and your version might even become incompatible. This approach at least would avoid that.
And to get your superscripted 2, see CSS :before superscript "6"?.
if you look at price.phtml you will see there are many repetitions of price and special price, as the file is used to cover every possible price permutation - product type and tax display etc. Step through each price echo and add [WHAT EVER] to the output until you find the code being fired for your particular instance and then add the m2 code to it.
EDIT: Looks like you are editing the wrong file. You should edit template/catalog/product/price.html, not template/catalog/product/view/price.phtml. You can see from your screen grab and your code they are not the same. Your code is echo'ing 'old price' which doesnt appear.

Magento checkout working except for progress boxes

I have recently been having problems with Magento's one page checkout system.
At the moment it is working in a basic way, but the progress steps which are normally displayed on the right hand side are not being updated when the steps are completed. The step headings are showing up (Billing Address, Shipping Address, etc.), and I can control their styles through the boxes.css settings, but they don't get filled in with the content as the customer step through the process.
I have tried a number of solutions, including:
changing the xml and
tweaking the opchecout.js file
What is the best way to debug something like this?
check that the ID of the block you insert matches the ID that is refreshed by the JavaScript function. I had that problem. If you are using the base/default/js/opcheckout.js file, it should be
id='checkout-progress-wrapper'
like so (in your onepage.phtml template):
<div id="checkout-progress-wrapper">
<?php echo $this->getChildHtml('checkoutProgress') ?>
</div>
Best if you check the js file also

Am I using Html.Raw() safely?

I have an ecommerce gift store where users can fill out a gift-card for their recipient.
In order to fill out the card, I have the users enter text into a multiline textbox.
When I display the gift-card on the final review page, I have to spit out the information with Html.Raw so that Newlines are being displayed properly. I'm doing this:
#(Model.GiftCard.Text != null ? Html.Raw(Model.GiftCard.Text.Replace(char.ConvertFromUtf32(13),"<br />")) : Html.Raw(""))
I'm frightened that i'm entering dangerous territory using Html.Raw on values that were user-entered. However, when I go back to the gift-card entry page, the page breaks when I try to do something like "This is my gift card! (scripttag)alert('test');(/scripttag)"... so I feel like .net will catch any malicious entries during that point.
Am I safe to proceed like this? It seems that since the gift-card entry page is running validations against malicious code, I should be okay to use HtmlRaw later to display newline html that I'm putting in myself...
(I replaced the actual script tag with this (scripttag) thing above so it will show in stackoverflow)
Use a regular expression in your view model to make sure people only enter A-Za-z0-9 and whatever else you think should use such as :) =] type of stuff. Screening this stuff front end is better than second guessing it on the way out.
How about using a
<pre></pre>
tag instead? This would allow returns to display in HTML without the need for Html.Raw?

Magento Module action on ProductView

I have create a module which at this point does nothing but exist the next step I need to figure out is how to make it does something when someone views the a product at this point I don't care if it says hello world next to the image
can someone help me I can't seem to figure out what I need to extend if i need to use and observer or what I seem to be lost .... or drowning
Depending on what you want to accomplish, you could go in many different directions from here. If you're looking for visual feedback, creating a new block and adding it to the product page might be a good direction. Try creating a new block in your module (Yournamespace_Yourmodule_Block_Product_View in the file app/code/local/Yournamespace/Yourmodule/Block/Product/View.php) and define a method toHtml in that block that echos some HTML (say "hello world"). Look at other blocks in the system to see how to set up such a class (what to descend from, etc). Later on, you'll want to turn this into a proper template, but this approach will help you understand blocks. Check Alan's other tutorials for how to set up your config.xml to define where blocks are found.
Now, inside your theme, in /templates/catalog/product/view.php, create an instance of your block and display it's contents like this:
<?php print $this->getLayout()->createBlock("yourmodule/product_view")->toHtml(); ?>
This should echo some HTML onto the product view page.
I want to emphasize that this skips several of the steps to doing it the "right" way, but it should get you quick visual feedback and help you understand how a page is built inside of magento.

Resources