WordPress.org

Ready to get started?Download WordPress

Forums

Simple Cart & Buy Now
[resolved] adding div to item options in display.php (5 posts)

  1. rosyb
    Member
    Posted 9 months ago #

    I have tweaked the css to change the styling of the add to cart options, and this has worked fine for the products that are simple. But for products where there are various options, eg size or colour, the css changes are not working.

    Therefore, I am wanting to add a div around the item option section of the code, but my php skills are basic and although I can add a div it is causing the product name to vanish! Below is the code from display.php from line 184 onwards .... including my attempt to add <div class='item_options_box'>:

    $output .= "<p id='cartname'>".$name . "</p>";
    		$output .= "<p id='cartcontent'>";
    
    		if (!empty ($item['options'])){
     			if ( $item['options_name'] != "" ) {
     	  	   	$output .= $item['options_name'].": \n";
    		 	}
    
    			$output .= "<input type='hidden' value='".$item['options_name']."' name='item_options_name' class ='item_options_name' />\n";
    			$options = explode(',',$item['options']);
                $output = "<div class='item_options_box'>\n";
    			$output .= "<select name='item_options' class = 'item_options' >\n";
    			foreach ($options as $option){
    				$info = explode(':',$option);
    				if (count($info) == 1) {
    					$output .= "<option value='".$info[0]."'>".$info[0]." (". $currency.number_format($item['price'],2) . ")</option>\n";
    				} else {
    					$output .= "<option value='".$info[0].":" . $info[1]. "'>".$info[0]." (". $currency.number_format($info[1],2) . ")</option>\n";
    				}
    			}
    			$output .= "</select>\n";
    			$output .= "<br/>\n";
    
    		} else {
    			$output .= 	__("Unit Price: ",'SCABN').trim($currency.number_format($item['price'],2)).__(" each",'SCABN')."<br/>";
    
    		}
    
    		if(array_key_exists('qty_field',$item)) {
    			$output .= __("Qty:",'SCABN');
    			$output .= "<input type='text' class='item_qty' value='1' size='2' name='item_qty'/>\n";
    		} else {
    			$output .= "<input type='hidden' class='item_qty' value='1' size='2' name='item_qty'/>\n";
    		}
    
    		if (array_key_exists('no_cart',$item)) {
    			$output .= "<input type='hidden' value='true' name='no_cart'/>\n";
    		}
    		if (array_key_exists('b_title',$item)) {
    			$b_title=$item['b_title'];
    		} else {
    			$b_title=__('Add to Cart','SCABN');
    		}
    		$output .= "<input type='submit' id='".$item_id."' ".$add_class." name='add' value='".$b_title."'/>\n";
                    $output .= "</div>\n";
    		$output .= "</form>\n";
    		$output .= "</p>\n";
                    $output .= "</div>\n";

    http://wordpress.org/plugins/simple-cart-buy-now/

  2. rosyb
    Member
    Posted 9 months ago #

    oops, url for the page is http://176.32.230.27/savethepuffer.co.uk/puffer-shop/, thanks!

  3. bluey80
    Member
    Plugin Author

    Posted 9 months ago #

    I think you are missing the closing </div> for your <div class='item_options_box'>:

  4. rosyb
    Member
    Posted 9 months ago #

    thanks for the tip, but I did put it in further down ..... it is the fourth line from the bottom in the code shown ... but could well be in the wrong place!

  5. bluey80
    Member
    Plugin Author

    Posted 9 months ago #

    If you want to add a div around the item options, you will want to close the div right after the close of the <options> tag.

    $output = "<div class='item_options_box'>\n";
    $output .= "<select name='item_options' class = 'item_options' >\n";
    foreach ($options as $option){
        $info = explode(':',$option);
        if (count($info) == 1) {
            $output .= "<option value='".$info[0]."'>".$info[0]." (".  $currency.number_format($item['price'],2) . ")</option>\n";
        } else {
    	$output .= "<option value='".$info[0].":" . $info[1]. "'>".$info[0]." (". $currency.number_format($info[1],2) . ")</option>\n";
        }
    }
    
    $output .= "</select>\n";
    $output .= "</div>\n";
    $output .= "<br/>\n";

    (And maybe remove the
    as the new css can handle that.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags