I am trying to work on the price fields error that occurs in twitter related themes.
so the error:
when you select on a category and if the price should not be shown it should hide the price field.
I have narrowed it down to a script in the core, but I don't want to change the core-- duh!
so how do I bring that function over into the themes function?
here is the cores syntax(is that the right term?) that I want into the theme
static public function plugin_post_item($case = 'form') {
?>
<script type="text/javascript">
var catPriceEnabled = new Array();
<?php
$categories = Category::newInstance()->listAll(false);
foreach($categories as $c) {
echo 'catPriceEnabled['.$c['pk_i_id'].'] = '.$c['b_price_enabled'].';';
}
?>
$("#catId").change(function(){
var cat_id = $(this).val();
<?php if(OC_ADMIN) { ?>
var url = '<?php echo osc_admin_base_url(true); ?>';
<?php } else { ?>
var url = '<?php echo osc_base_url(true); ?>';
<?php } ?>
var result = '';
if(cat_id != '') {
if(catPriceEnabled[cat_id] == 1) {
$("#price").closest("div").show();
} else {
$("#price").closest("div").hide();
$('#price').val('') ;
}
$.ajax({
type: "POST",
url: url,
data: 'page=ajax&action=runhook&hook=item_<?php echo $case;?>&catId=' cat_id,
dataType: 'html',
success: function(data){
$("#plugin-hook").html(data);
}
});
}
});
$(document).ready(function(){
var cat_id = $("#catId").val();
<?php if(OC_ADMIN) { ?>
var url = '<?php echo osc_admin_base_url(true); ?>';
<?php } else { ?>
var url = '<?php echo osc_base_url(true); ?>';
<?php } ?>
var result = '';
if(cat_id != '') {
if(catPriceEnabled[cat_id] == 1) {
$("#price").closest("div").show();
} else {
$("#price").closest("div").hide();
$('#price').val('') ;
}
$.ajax({
type: "POST",
url: url,
data: 'page=ajax&action=runhook&hook=item_<?php echo $case;?>&catId=' cat_id,
dataType: 'html',
success: function(data){
$("#plugin-hook").html(data);
}
});
}
});
</script>
<div id="plugin-hook">
</div>