Product Size Guide - Tabs

Open to all! Ask other shopowners for help.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Product Size Guide - Tabs

Post by LeeFoster »

Before I start working on this has anyone created a size guide tab for stores that sell things like t-shirts?

The site I'm currently working on sells items in different sizes (small, medium, large etc) I'd like to be able to create a table to show the size guide in a tab and then select which size guide to use for which product or to not use one at all.


Join The Code Co-op to get access to your library in the Code Co-op Forum
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Product Size Guide - Tabs

Post by LeeFoster »

Right guys,

I am back from my holidays and I am starting to look at creating this.

Here is what I am looking to achieve.

In admin I will be creating a section where size guides can be created, this will be done by first creating a size guide then by adding the various sizes to the guide. You will then be able to assign a size guide to a product.

This will allow the adding of size guides based on the product, I use T-shirts in my previous example so will do so again. Take the difference between mens and womens.

Mens will show Small, Medium, Large etc with the measurement being chest in cm/inch, Womens however will show 8, 10, 12 etc with the measurement being bust in cm/inch. Along with those for children.

On the front end I aim to have this displayed in a product tab.

So I will need to create

- Relevant database tables
- Admin section pages
- Hook to add to Product Admin
- PI tab module

There may be more to this but I will keep you updated. If anyone wishes to contribute feel free to drop me a message.
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Product Size Guide - Tabs

Post by radhavallabh »

LeeFoster wrote: Mon Aug 08, 2022 9:09 am Right guys,

I am back from my holidays and I am starting to look at creating this.

Here is what I am looking to achieve.

In admin I will be creating a section where size guides can be created, this will be done by first creating a size guide then by adding the various sizes to the guide. You will then be able to assign a size guide to a product.

This will allow the adding of size guides based on the product, I use T-shirts in my previous example so will do so again. Take the difference between mens and womens.

Mens will show Small, Medium, Large etc with the measurement being chest in cm/inch, Womens however will show 8, 10, 12 etc with the measurement being bust in cm/inch. Along with those for children.

On the front end I aim to have this displayed in a product tab.

So I will need to create

- Relevant database tables
- Admin section pages
- Hook to add to Product Admin
- PI tab module

There may be more to this but I will keep you updated. If anyone wishes to contribute feel free to drop me a message.
This will be surely a great addition to the product features;

We can also add a picture scale beside the table to understand what each pointer mentioned refers too...

Regds./
radhavallabh
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Product Size Guide - Tabs

Post by burt »

Potential things to try (on a new test shop), as these may more or less do the job you need, maybe (they ring a bell with me based on my reading of your posts);

S02E06 - Product Terms
along with S03E04 - Terms Tab

Or maybe this;

S04E10 - Product Specs
along with S06E06 - Specs extension
I am not here to build for you.
I am here to build with you. Let's help each other.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Product Size Guide - Tabs

Post by LeeFoster »

burt wrote: Mon Aug 08, 2022 4:41 pm Potential things to try (on a new test shop), as these may more or less do the job you need, maybe (they ring a bell with me based on my reading of your posts);

S02E06 - Product Terms
along with S03E04 - Terms Tab

Or maybe this;

S04E10 - Product Specs
along with S06E06 - Specs extension
Product Specs I am already using. Product Terms I don't think will work.

I am using Product Specs as the basis for this though.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Product Size Guide - Tabs

Post by LeeFoster »

Right guys,

Some progress is being made and I'm almost there, but I need help with a few issues.

First up, when adding the value options I'm dynamically creating x number of fields to add them eg. 3 fields for small, medium, large. However when I click save these values are not passed to the sql query and therefore not to the database.

JS code

Code: Select all

$(document).ready(function() {
  $('select').on('change', function() {
    var selectValue = $(this).val();
    $.ajax({
      type: "POST",
      url: "ext/scripts/get_sizes.php",
      data: {
        selected: selectValue
      },
      success: function (data) {
        $('#values').html(data);
        // Stuff
      },
      error: function (data) {
        // Stuff
      }
    });
  });
});
Query and result

Code: Select all

$selectedValue = $_POST['selected'];

	$sqlQuery = $db->query("SELECT * FROM products_sizes where products_sizes_id = '$selectedValue'");
		$string = $sqlQuery->fetch_assoc();
		$str_arr = preg_split ("/\,/", $string['products_sizes_sizes']);

foreach ($str_arr as $id) {
	echo '<input class="form-control input-sm" name="val[]" value="'. $id .'"> ';				   				   				  
				}
Submit code

Code: Select all

$member_id = Text::input($_POST['member_id']);
  $member_sort = Text::input($_POST['member_sort']);
  $group_id = Text::input($_POST['group_id']);
$a = implode(",", $_POST['val']);

  foreach ($languages as $l) {
    $member_name = Text::prepare($_POST['member_name'][$l['id']]);
	

    $db->query("INSERT INTO products_sizes_values (products_sizes_values_id, language_id, products_sizes_id, products_sizes_values_name, products_sizes_values, psv_sort_order) VALUES (" . (int)$member_id . ", " . (int)$l['id'] . ", " . (int)$group_id . ", '" . $db->escape($member_name) . "', '" . $a . "', " . (int)$member_sort . ")");
  }

  return $Admin->link('products_sizes.php', $page_info);
Any help to get this over the line would be much appreciated.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Product Size Guide - Tabs

Post by ecartz »

In the Javascript that posts, you are calling it selected. In the PHP code that submits, you are calling it val. Those two need to match.

Code: Select all

$a = implode(',', $_POST['selected']);
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Product Size Guide - Tabs

Post by LeeFoster »

ecartz wrote: Thu Aug 11, 2022 12:00 pm In the Javascript that posts, you are calling it selected. In the PHP code that submits, you are calling it val. Those two need to match.

Code: Select all

$a = implode(',', $_POST['selected']);
The javascript doesn't post the form, it grabs the number of values then creates an input for each one. They're 2 separate functions.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Product Size Guide - Tabs

Post by LeeFoster »

I'm being told by other sources that it is because the dynamic inputs are outside the form. But all the inputs appear to be outside the form, it is using code mainly from products_tags.php
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Product Size Guide - Tabs

Post by ecartz »

LeeFoster wrote: Fri Aug 12, 2022 12:34 pm I'm being told by other sources that it is because the dynamic inputs are outside the form. But all the inputs appear to be outside the form, it is using code mainly from products_tags.php
I looked at products_tags.php and things there are inside the forms (there's more than one). So it's not clear to me what you mean by "inputs appear to be outside the form".

You don't include enough context for me to say that about your page. In general, the input should appear after a <form or echo Form( and before the </form>.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply