Convert checkbox to dropdown using PHP - php

I'm using WP Job Manager plugin, and I want to convert the Job type checkbox into dropdown (the gray background).
I tried to convert it but I have no luck. How to do this using selected() function? Thanks
Here's the snippet that I tried:
<?php if ( ! is_tax( 'job_listing_type' ) && empty( $job_types ) ) : ?>
<ul class="job_types">
<?php foreach ( get_job_listing_types() as $type ) : ?>
<select name="filter_job_type[]">
<option value='Collections' ". selected( $types['collections'], 'collections', false .">Collections</option>
</select>
<?php endforeach; ?>
Here's the snippet of the job type checkbox:
<?php if ( ! is_tax( 'job_listing_type' ) && empty( $job_types ) ) : ?>
<ul class="job_types">
<?php foreach ( get_job_listing_types() as $type ) : ?>
<li>
<label for="job_type_<?php echo $type->slug; ?>" class="<?php echo sanitize_title( $type->name ); ?>">
<input type="checkbox" name="filter_job_type[]" value="<?php echo $type->slug; ?>" <?php checked( in_array( $type->slug, $selected_job_types ), true ); ?> id="job_type_<?php echo $type->slug; ?>" /> <?php echo $type->name; ?>
</label>
</li>
<?php endforeach; ?>
</ul>
<input type="hidden" name="filter_job_type[]" value="" />
<?php elseif ( $job_types ) : ?>
<?php foreach ( $job_types as $job_type ) : ?>
<input type="hidden" name="filter_job_type[]" value="<?php echo sanitize_title( $job_type ); ?>" />
<?php endforeach; ?>
Here's the link: http://bit.ly/1OEzAwz

This might do the trick for you:
<script>
var select=jQuery(document.createElement('select')).insertBefore(jQuery('.load_more_jobs'));
jQuery('.job_listing a').each(function(){
jQuery(document.createElement('option')).appendTo(select).val(this.href).html(jQuery(this).html());
});
jQuery('.entry-content select').on('change',function(){
if(!this.value)return;
console.log(this.options[this.selectedIndex].innerHTML+": "+this.value);
window.location.href=this.value;
});
jQuery('.job_listing').hide();
</script>

You can try this one at the head tag
<script>
(function($) {
"use strict"
$(function() {
var $job_types_select = $('<select class="job_types_select"></select>');
var $job_types_ul = $('form.job_filters ul.job_types');
var $job_type_hidden = $('<input type="hidden" name="filter_job_type[]"/>');
$job_types_ul.find('li').each(function() {
var $li = $(this);
var label_text = $li.find('label').text();
var value = $li.find('input:checkbox').val();
var $option = $('<option></option>');
$option.text(label_text);
$option.attr({value: value});
$job_types_select.append($option);
});
$job_types_select.change(function() {
var value = $(this).val();
$('input:hidden[name="filter_job_type[]"]').val(value);
var target = $( this ).closest( 'div.job_listings' );
target.triggerHandler( 'update_results', [ 1, false ] );
});
$job_types_ul.after($job_type_hidden);
$job_types_ul.replaceWith($job_types_select);
});
})(jQuery);
</script>

Related

Overriding woocommerce shipping calculator in child theme

I have overridden the woocommerce shipping calculator and it works. However, when I change countries, the 'State' input field appears when I have set that as a hidden field. If I then change back to my home country, Australia, the State field remains, but becomes a dropdown and is populated with the States of Australia. This field is part of the original theme's shipping-calculator.php, not my child theme one.
I'm not sure how this is happening since my child theme works fine until I change countries. I am trying to include the use of the AddressFinder widget into my cart shipping calculator when the customer is from Australia, and not use it when the customer is from another country.
defined( 'ABSPATH' ) || exit;
do_action( 'woocommerce_before_shipping_calculator' ); ?>
<script>
(function(){
var cartwidget, initAF = function(){
cartwidget = new AddressFinder.Widget(
document.getElementById('address_field'),
'<AddressFinder Key Here>',
'AU',
{
"address_params": {}
}
);
cartwidget.on("result:select", function(fullAddress, metaData) {
var combinedAddressLine1And2;
if ( metaData.address_line_2 ) {
combinedAddressLine1And2 = metaData.address_line_1 + ', ' + metaData.address_line_2
} else {
combinedAddressLine1And2 = metaData.address_line_1
}
if ( document.getElementById("calc_shipping_country").value == "Australia" ) {
document.getElementById('calc_shipping_address_1').value = combinedAddressLine1And2;
document.getElementById('calc_shipping_state').value = metaData.state_territory;
document.getElementById('calc_shipping_postcode').value = metaData.postcode;
} else {
document.getElementById('calc_shipping_address_1').value = '';
document.getElementById('calc_shipping_state').value = '';
document.getElementById('calc_shipping_postcode').value = '';
}
//window.alert(document.getElementById('calc_shipping_address_1').value);
document.getElementById('calc_shipping_city').value = metaData.locality_name;
});
};
function downloadAF(f){
var script = document.createElement('script');
script.src = 'https://api.addressfinder.io/assets/v3/widget.js';
script.async = true;
script.onload=f;
document.body.appendChild(script);
};
document.addEventListener("DOMContentLoaded", function () {
downloadAF(initAF);
});
})();
function country_updated() {
if ( document.getElementById("calc_shipping_country").value == "Australia") {
document.getElementById("address_field").type = 'text';
document.getElementById("calc_shipping_city").type = 'hidden';
} else {
document.getElementById("calc_shipping_city").type = 'text';
document.getElementById("address_field").type = 'hidden';
}
}
</script>
<form class="woocommerce-shipping-calculator" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
<?php printf( '%s', esc_html( ! empty( $button_text ) ? $button_text : __( 'Calculate shipping', 'woocommerce' ) ) ); ?>
<section class="shipping-calculator-form" style="display:none;">
<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_country', true ) ) : ?>
<p class="form-row form-row-wide" id="calc_shipping_country_field">
<select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state country_select" onchange="country_updated()">
<option value=""><?php esc_html_e( 'Select a country…', 'woocommerce' ); ?></option>
<?php
foreach ( WC()->countries->get_shipping_countries() as $key => $value ) {
echo '<option value="' . esc_attr( $key ) . '"' . selected( WC()->customer->get_shipping_country(), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
}
?>
</select>
</p>
<?php endif; ?>
<p class="form-row form-row-wide" id="shipping_address_field">
<input type="text" placeholder="<?php esc_attr_e( 'Enter Address Here', 'woocommerce' ); ?>" id="address_field" name="address_field" placeholder="Enter address here" class="address-search">
</p>
<p class="form-row form-row-wide" id="calc_shipping_address_field_1">
<input type="hidden" name="calc_shipping_address_1" id="calc_shipping_address_1" />
</p>
<p class="form-row form-row-wide" id="calc_shipping_city_field">
<input type="hidden" name="calc_shipping_city" id="calc_shipping_city" />
</p>
<p class="form-row form-row-wide" id="calc_shipping_state_field">
<input type="hidden" name="calc_shipping_state" id="calc_shipping_state" />
</p>
<p class="form-row form-row-wide" id="calc_shipping_postcode_field">
<input type="hidden" name="calc_shipping_postcode" id="calc_shipping_postcode" />
</p>
<p><button type="submit" name="calc_shipping" value="1" class="button"><?php esc_html_e( 'Update', 'woocommerce' ); ?></button></p>
<?php wp_nonce_field( 'woocommerce-shipping-calculator', 'woocommerce-shipping-calculator-nonce' ); ?>
</section>
</form>
<?php do_action( 'woocommerce_after_shipping_calculator' ); ?>
When the customer is from Australia - it should display the country select input and an address input box - which has the AddressFinder widget on it. When the customer is from another country, it should display the country select and the city input field. Instead, when another country is selected, the state field shows as well. And when changing back to Australia, the State field remains.
I figured out the issue. In the 'Country' select, I had left it's class as: class="country_to_state country_select" - so this was obviously populating and calling the State input field. I also realised my javascript should have been checking the country select value for "AU" not "Australia".

Need to change check box to multi select box php

I need to help to convert checkbox to multi select drop down PHP code -
<?php if ( ! is_tax( 'job_listing_type' ) && empty( $job_types ) ) : ?>
<ul class="job_types">
<?php foreach ( get_job_listing_types() as $type ) : ?>
<li><label for="job_type_<?php echo $type->slug; ?>" class="<?php echo sanitize_title( $type->name ); ?>"><input type="checkbox" name="filter_job_type[]" value="<?php echo $type->slug; ?>" <?php checked( in_array( $type->slug, $selected_job_types ), true ); ?> id="job_type_<?php echo $type->slug; ?>" /> <?php echo $type->name; ?></label></li>
<?php endforeach; ?>
</ul>
<input type="hidden" name="filter_job_type[]" value="" />
<?php elseif ( $job_types ) : ?>
<?php foreach ( $job_types as $job_type ) : ?>
<input type="hidden" name="filter_job_type[]" value="<?php echo sanitize_title( $job_type ); ?>" />
<?php endforeach; ?>
<?php endif; ?>

How can I create a php mail handler for a dynamically created form

I am creating a form builder plugin for wordpress allowing users to build their own custom forms.
I have managed to design the form builder, now I am looking at the form submit handler. I'm using a php handler, something similar to this:
<?php
// process.php
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
// validate the variables ======================================================
// if any of these variables don't exist, add an error to our $errors array
if (empty($_POST['name']))
$errors['name'] = 'Name is required.';
if (empty($_POST['email']))
$errors['email'] = 'Email is required.';
if (empty($_POST['superheroAlias']))
$errors['superheroAlias'] = 'Superhero alias is required.';
// return a response ===========================================================
// if there are any errors in our errors array, return a success boolean of false
if ( ! empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
// if there are no errors process our form, then return a message
// DO ALL YOUR FORM PROCESSING HERE
// THIS CAN BE WHATEVER YOU WANT TO DO (LOGIN, SAVE, UPDATE, WHATEVER)
// show a message of success and provide a true success variable
$data['success'] = true;
$data['message'] = 'Success!';
}
// return all our data to an AJAX call
echo json_encode($data);
However, as mentioned, my forms are created dynamically, so I can't use hard coded variables.
I'm not sure of a good way forward with this, can anyone suggest a way I can use the dynamically created variables in my main form builder file as part of this handler file?
Here is my php builder code:
<form action="./includes/process.php" method="POST">
<?php foreach ( wp_parse_id_list( $widget[ 'form_builder_ids' ] ) as $form_builder_key ) {
....
<div class="media-body <?php echo ( isset( $item['design']['fonts'][ 'align' ] ) ) ? $item['design']['fonts'][ 'align' ] : ''; ?>">
<?php if( $this->check_and_return( $item, 'label') ) { ?>
<label>
<?php echo $item['label']; ?>
<?php if( $this->check_and_return( $item, 'required') ) { ?>
<span class="required" style="color:#c0392b;">*</span>
<?php } ?>
</label>
<?php } ?>
<?php if( $this->check_and_return( $item, 'input_type') ) { ?>
<?php
$input_type_array = array('select', 'textarea', 'checkbox', 'radio');
if( !in_array( $item['input_type'] ,$input_type_array ) ) {?>
<input type="<?php echo $item['input_type']; ?>" name="<?php echo $item['input_name']; ?>" <?php if( $this->check_and_return( $item, 'required') ) { echo 'required'; } ?>>
<?php } else if ($item['input_type'] == 'textarea') { ?>
<textarea name="<?php echo $item['input_name']; ?>" <?php if( $this->check_and_return( $item, 'required') ) { echo 'required'; } ?>></textarea>
<?php } else if ($item['input_type'] == 'select') { ?>
<select name="<?php echo $item['input_name']; ?>" <?php if( $this->check_and_return( $item, 'required') ) { echo 'required'; } ?>>
<?php foreach(explode("\n", $item['select_options']) as $select_option) { ?>
<option value="<?php echo preg_replace('/\s+/','', $select_option); ?>"><?php echo $select_option; ?></option>
<?php } ?>
</select>
<?php } else if ($item['input_type'] == 'checkbox') { ?>
<?php foreach(explode("\n", $item['select_options']) as $select_option) { ?>
<input type="checkbox" name="<?php echo $item['input_name']; ?>" value="<?php echo preg_replace('/\s+/','', $select_option); ?>" <?php if( $this->check_and_return( $item, 'required') ) { echo 'required'; } ?>><?php echo $select_option; ?>
<?php } ?>
<?php } else if ($item['input_type'] == 'radio') { ?>
<?php foreach(explode("\n", $item['select_options']) as $select_option) { ?>
<input type="radio" name="<?php echo $item['input_name']; ?>" value="<?php echo preg_replace('/\s+/','', $select_option); ?>" <?php if( $this->check_and_return( $item, 'required') ) { echo 'required'; } ?>><?php echo $select_option; ?>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
....
</form>
I'd achieve something like this by setting an incremental javascript global var:
var x = 0;
function addForm(){
var formHTML = '<form onsubmit = "submitForm(' + x + '); return false;"> <input id = "name' + x + '" ... </form>';
x = x+1;
}
function submitForm(formIdentifier){
var name = document.getElementById("name"+formIdentifier).value; //how you can get the form values from dynamic forms
//process form with ajax from here
}
Where addForm() is that code that would add the form to the page, and submitForm is where you would process the data from a dynamic form submit event.
Let me know if you need some more clarification.

Echo Selected Value Wordpress

I'm stuck with this. I can't get the selected option to display the selected item in the backend of Wordpress. It saves to the database and I can echo it out on the front end. Pulling my hair out now.
<?php add_action( 'add_meta_boxes', 'dynamic_add_custom_box' );
/* Do something with the data entered */
add_action( 'save_post', 'dynamic_save_postdata' );
/* Adds a box to the main column on the Post and Page edit screens */
function dynamic_add_custom_box() {
add_meta_box(
'dynamic_sectionid',
__( 'Plot Status', 'myplugin_textdomain' ),
'dynamic_inner_custom_box',
'house_type');
}
/* Prints the box content */
function dynamic_inner_custom_box() {
global $post;
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );
?>
<div id="meta_inner">
<?php
//get the saved meta as an arry
$plots = get_post_meta($post->ID,'plots',true);
$c = 0;
if ( count( $plots ) > 0 ) {
foreach( $plots as $plotno ) {
if ( isset( $plotno['title'] ) || isset( $plotno['plotno'] ) || isset( $plotno['development'] ) ) {
printf( '
<p>Plot Number: <input type="text" name="plots[%1$s][title]" value="%2$s" />
Status : <select name="plots[%1$s][plotno]" value="%3$s">
<option value="Not Released" '. selected( 'plots[%1$s][plotno]', "Not Released" ).'>Not Released</option>
<option value="Available" '. selected( 'plots[%1$s][plotno]', "Available" ) .'>Available</option>
<option value="Reserved" '. selected( 'plots[%1$s][plotno]', "Reserved" ) .'>Reserved</option>
<option value="Sold" '. selected( 'plots[%1$s][plotno]', "Sold" ) .'>Sold</option>
</select>
Development : <input type="text" name="plots[%1$s][development]" value="%4$s" />
<span class="remove" style="color:red;cursor:pointer;padding-left:10px;">%5$s</span></p>', $c, $plotno['title'], $plotno['plotno'], $plotno['development'], __( 'Remove' ) );
$c = $c +1;
}
}
}
?>
<span id="here"></span>
<div class="button">
<span class="add"><?php _e('Add Plot Number'); ?></span></div>
<script>
var $ =jQuery.noConflict();
$(document).ready(function() {
var count = <?php echo $c; ?>;
$(".add").click(function() {
count = count + 1;
$('#here').append('<p> Plot Number: <input type="text" name="plots['+count+'][title]" value="" /> Status : <select name="plots['+count+'][plotno]" value=""><option value="" >Not Released</option><option value="">Available</option><option value="">Reserved</option> <option value="">Sold</option> </select> Development : <input type="text" name="plots['+count+'][development]" value="" /> <span style="remove" >Remove</span></p>' );
return false;
});
$(".remove").live('click', function() {
$(this).parent().remove();
});
});
</script>
</div><?php
}
What I've done is I've tried to edit this by adding a drop down select option. tutorial
I did this in script. Its working
add_action( 'add_meta_boxes', 'dynamic_add_custom_box' );
/* Do something with the data entered */
add_action( 'save_post', 'dynamic_save_postdata' );
/* Adds a box to the main column on the Post and Page edit screens */
function dynamic_add_custom_box() {
add_meta_box( 'dynamic_sectionid', __( 'Plot Status', 'myplugin_textdomain' ), 'dynamic_inner_custom_box','post');
}
/* Prints the box content */
function dynamic_inner_custom_box() {
global $post;
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );
?>
<div id="meta_inner">
<?php
//get the saved meta as an arry
$plots = get_post_meta($post->ID,'plots',true);
$c = 0;
if ( count( $plots ) > 0 ) {
foreach( $plots as $plotno ) {
if ( isset( $plotno['title'] ) || isset( $plotno['plotno'] ) || isset( $plotno['development'] ) ) {
printf( '
<p>Plot Number: <input type="text" name="plots[%1$s][title]" value="%2$s" />
Status : <select name="plots[%1$s][plotno]" class="plotnoclass_%1$s">
<option value="Not Released">Not Released</option>
<option value="Available">Available</option>
<option value="Reserved">Reserved</option>
<option value="Sold">Sold</option>
</select>
Development : <input type="text" name="plots[%1$s][development]" value="%4$s" />
<span class="remove" style="color:red;cursor:pointer;padding-left:10px;">%5$s</span></p>', $c, $plotno['title'], $plotno['plotno'], $plotno['development'], __( 'Remove' ) );
echo "<script>jQuery(\".plotnoclass_$c\").val('".$plotno['plotno']."');</script>";
$c = $c +1;
}
}
}
?>
<span id="here"></span>
<div class="button">
<span class="add"><?php _e('Add Plot Number'); ?></span></div>
<script>
var $ =jQuery.noConflict();
$(document).ready(function() {
var count = <?php echo $c; ?>;
$(".add").click(function() {
count = count + 1;
$('#here').append('<p> Plot Number: <input type="text" name="plots['+count+'][title]" value="" /> Status : <select name="plots['+count+'][plotno]" value=""><option value="" >Not Released</option><option value="">Available</option><option value="">Reserved</option> <option value="">Sold</option> </select> Development : <input type="text" name="plots['+count+'][development]" value="" /> <span style="remove" >Remove</span></p>' );
return false;
});
$(".remove").live('click', function() {
$(this).parent().remove();
});
});
</script>
</div><?php
}

Trying to send a hidden input value to next page

I am trying to tweak Wordpress Jigoshop according to my customer's needs and I got a bit stuck. What I need is: when a product variation is selected, some additional options appear in the form of radio buttons which customers must chose. I've managed to get everything working, but what I need now is to send the selected radio button to the cart, checkout and so on when the submit button is clicked.
I am trying to use their product customization function to do this and their function is:
if (!function_exists('jigoshop_product_customize_panel')) {
function jigoshop_product_customize_panel() {
global $_product;
if ( isset( $_POST['Submit'] ) && $_POST['Submit'] == 'Save Personalization' ) {
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom_products[$_POST['customized_id']] = trim( wptexturize( $_POST['jigoshop_customized_product'] ));
jigoshop_session::instance()->customized_products = $custom_products;
}
if ( get_post_meta( $_product->ID , 'customizable', true ) == 'yes' ) :
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom = isset( $custom_products[$_product->ID] ) ? $custom_products[$_product->ID] : '';
$custom_length = get_post_meta( $_product->ID , 'customized_length', true );
$length_str = $custom_length == '' ? '' : sprintf( __( 'You may enter a maximum of %s characters.', 'jigoshop' ), $custom_length );
echo '<div class="panel" id="tab-customize">';
echo '<p>' . apply_filters('jigoshop_product_customize_heading', __('Enter your personal information as you want it to appear on the product.<br />'.$length_str, 'jigoshop')) . '</p>';
?>
<form action="" method="post">
<input type="hidden" name="customized_id" value="<?php echo esc_attr( $_product->ID ); ?>" />
<?php
if ( $custom_length == '' ) :
?>
<textarea
id="jigoshop_customized_product"
name="jigoshop_customized_product"
cols="60"
rows="4"><?php echo esc_textarea( $custom ); ?>
</textarea>
<?php else : ?>
<input
type="text"
id="jigoshop_customized_product"
name="jigoshop_customized_product"
size="<?php echo $custom_length; ?>"
maxlength="<?php echo $custom_length; ?>"
value="<?php echo esc_attr( $custom ); ?>" />
<?php endif; ?>
<p class="submit"><input name="Submit" type="submit" class="button-alt add_personalization" value="<?php _e( "Save Personalization", 'jigoshop' ); ?>" /></p>
</form>
<?php
echo '</div>';
endif;
}
}
I tried modifying their function to suit my needs and this is what I've come up with (where get_cod is the id and name of the hidden input and "Adauga in cos" is the value of my submit button):
if (!function_exists('salveaza_cod_material')) {
function salveaza_cod_material() {
global $_product;
if ( isset( $_POST['submit']) && $_POST('submit') == 'Adauga in cos') {
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom_products[$_POST['customized_id']] = trim( wptexturize( $_POST['get_cod'] ));
jigoshop_session::instance()->customized_products = $custom_products;
}
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom = isset( $custom_products[$_product->ID] ) ? $custom_products[$_product->ID] : '';
}}
However the value isn't sent to the next page. Can anybody please help? Cheers!
Here's an update containing more of the code:
<form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="variations_form cart" method="post">
<fieldset class="variations">
<?php foreach ( $attributes as $name => $options ): ?>
<?php $sanitized_name = sanitize_title( $name ); ?>
<div>
<span class="select_label"><?php echo jigoshop_product::attribute_label('pa_'.$name); ?></span>
<select id="<?php echo esc_attr( $sanitized_name ); ?>" name="tax_<?php echo $sanitized_name; ?>">
<option value=""><?php echo __('Choose an option ', 'jigoshop') ?>…</option>
<?php foreach ( $options as $value ) : ?>
<?php if ( taxonomy_exists( 'pa_'.$sanitized_name )) : ?>
<?php $term = get_term_by( 'slug', $value, 'pa_'.$sanitized_name ); ?>
<option value="<?php echo esc_attr( $term->slug ); ?>"><?php echo $term->name; ?> </option>
<?php else : ?>
<option value="<?php echo esc_attr( sanitize_title( $value ) ); ?>"><?php echo $value; ?></option>
<?php endif;?>
<?php endforeach; ?>
</select>
</div>
<?php endforeach;?>
</fieldset>
<div id="piele-neagra" class="colors" style="display:none">
<ul class="materiale">
<li><input type="radio" name="piele-neagra" value="L73">
<p><img class="alignnone size-full wp-image-155" title="L73" src="http://www.scaune-directoriale.ro/wp-content/uploads/materiale/piele-neagra/L73.gif" alt="L73" width="72" height="72" /></p>
</li>
</ul>
</div>
<div id="stofa-mf" class="colors" style="display:none">
<ul class="materiale">
<li><input type="radio" name="tapiterie" value="MF01" />
...
<div id="stofa-rg" class="colors" style="display:none"> Stofa RG</div>
<div class="clear"></div>
<span id="cod_material"><?php echo esc_attr( $custom ); ?></span>
<span><?php echo trim( wptexturize( $_POST['get_cod'] )); ?></span>
<div class="single_variation"></div>
<?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
<div class="variations_button" style="display:none;">
<input type="hidden" name="variation_id" value="" />
<input type="hidden" name="customized_id" value="<?php echo esc_attr( $_product->ID ); ?>" />
<input type="hidden" id="get_cod" name="get_cod" value="" />
<input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
<div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
<input type="submit" id="submit_cart" class="button-alt" value="<?php esc_html_e('Add to cart', 'jigoshop'); ?>" />
</div>
<?php do_action('salveaza_cod_material'); ?>
<?php do_action('jigoshop_add_to_cart_form'); ?>
</form>
And this is the section of the cart that receives the value:
if ( !empty( $values['variation_id'] )) {
$product_id = $values['variation_id'];
} else {
$product_id = $values['product_id'];
}
$custom_products = (array) jigoshop_session::instance()->customized_products;
$custom = isset( $custom_products[$product_id] ) ? $custom_products[$product_id] : '';
if ( ! empty( $custom_products[$product_id] ) ) :
?>
<dl class="customization">
<dt class="customized_product_label"><?php echo apply_filters('jigoshop_customized_product_label', __('Personal: ','jigoshop') ); ?></dt>
<dd class="customized_product"><?php echo esc_textarea( $custom ); ?></dd>
</dl>
<? php
endif;
?>
It's just a typo: in if ( isset( $_POST['submit']) && $_POST('submit') == 'Adauga in cos'), replace $_POST('submit')by $_POST['submit']

Categories