News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Custom shipment integration using customer comment textarea as a workaround

Started by tutyi, December 01, 2012, 21:42:33 PM

Previous topic - Next topic

tutyi

Hi,

in my country there is a common shipment method called Pick Pack Pont. The owner of the system provides an xml file containing every address where you can pick up your purchase. It's unknown when will be any plugin for this system so I'm trying to solve it with a workaround. There is an input field below shipment and payment selection where you can search for the pickup points by jQuery autocomplete, then there is a checkbox. When it's checked the content written in the input field is duplicated in the customer-comment textarea.
The problem comes up in that moment. After checkout the customer comment doesn't exists in e-mails, orders, nowhere. Customer comments show up normally after checkout when I don't use the modification.
Does anybody have any tips? Thank you in advance!

Environment is Joomla 2.5.6 | Virtuemart 2.0.8. | PHP 5.3.15 | VM CSS/VM JQuery/Product scripts/Country scripts/External JQuery -> Enabled

In components/com_virtuemart/views/cart/tmpl/default.php i made the following modifications:

line91 /original/
<?php // Leave A Comment Field ?>
<div class="customer-comment marginbottom15">
<span class="comment"><?php echo JText::('COM_VIRTUEMART_COMMENT_CART'); ?></span><br/>
<textarea class="customer-comment" name="customer_comment" cols="60" rows="1"><?php echo $this->cart->customer_comment?></textarea>
</div>
<?php // Leave A Comment Field END ?>


modified
<?php // Leave A Comment Field ?>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<style>
    .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
    </style>
    <script>
    $(function() {
        function log( message ) {
            $( "<div/>" ).text( message ).prependTo( "#log" );
            $( "#log" ).attr( "scrollTop", 0 );
        }

        $.ajax({
            url: "http://allatparadicsom.hu/custom/core/validboltlista.xml",
            dataType: "xml",
            success: function( xmlResponse ) {
                var data = $( "Shop", xmlResponse ).map(function() {
                    return {
                        value: $( "ZipCode", this ).text() + " " +
                            ( $.trim( $( "City", this ).text() +
"," + $( "Address", this ).text() +
" | " + $( "Name", this ).text() +
" | " ) || "(unknown city)" ),
                        id: $( "Address", this ).text()
                    };
                }).get();
                $( "#birds" ).autocomplete({
                    source: data,
                    minLength: 0,
                    select: function( event, ui ) {
                        log( ui.item ?
                            "Selected: " + ui.item.value + ", Cím: " + ui.item.id :
                            "Nothing selected, input was " + this.value );
                    }
                });
            }
        });
    })(jQuery);
    </script>
<div class="ui-widget" style="float:right;">
<br />
  <form>
    <label for="birds"></label>
    <input id="birds" name="birds" size="54" />
    Pick Pack Pont helyes?:<input id="same" name="same" type="checkbox" />
  </form>
<br />
</div>

<div style="clear:both;">&nbsp;</div>

    <div class="customer-comment marginbottom15">
<span class="comment"><?php echo JText::('COM_VIRTUEMART_COMMENT_CART'); ?></span><br/>
<textarea class="customer-comment" name="customer_comment" cols="60" rows="1"><?php echo $this->cart->customer_comment?></textarea> <?php /* <input id="ppp-birds" class="customer-comment" name="customer_comment" size="54" value="<?php echo $this->cart->customer_comment; ?>" /> */ ?>
</div>

<script>
$(document).ready(function(){
$("input#same").click(function(){
if ($("input#same").is(':checked'))
{
// Checked, copy values
$("textarea.customer-comment").val($("input#birds").val());
}
else
{
// Clear on uncheck
$("textarea.customer-comment").val("");
}
});
})(jQuery);
</script>

<?php // Leave A Comment Field END ?>