Jump to content

jarvis

Members
  • Content Count

    459
  • Joined

  • Last visited

Community Reputation

1 Neutral

About jarvis

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. Hi All, I have a Bootstrap (v4) carousel. It has numerous slides but one slide has a video. For example: <div class="carousel-item" data-interval="10000"> <video id="player" loop> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4"><br> Your browser does not support the video tag. </video> <div class="carousel-caption d-md-block"> <h3 data-animation="animated flipInX"> This is the caption for slide 4 </h3> </div> </div> What I'm trying to do, is set the video to play only when you're on that slide (active) and pause when you either scroll away (via a click on the carousel arrows/indicators or the carousel interval). Therefore, I will use the event functionality (https://getbootstrap.com/docs/4.0/components/carousel/#events). As I'm using HTML 5 video tags, this is my solution: $('#carousel').carousel().on('slide.bs.carousel',function(){ $('.carousel-item').find('video').each(function(){ this.pause(); }); }); $('#carousel').carousel().on('slide.bs.carousel',function(){ $('.carousel-item active').find('video').each(function(){ this.play(); }); }); Unfortunately, it doesn't seem to work but I can't see why? Am I missing something very obvious?? Many thanks in advanced
  2. Hi All, I've a loop which creates an array as follows: $product_table[] = ['SKU' => $sku, 'Label' => $attribute_name, 'Value' => $term_obj->name ]; I'm then grouping the data by SKU code: #group the products by SKU $group_products = array(); foreach ($product_table as $element) : $group_products[$element['SKU']][] = $element; endforeach; Finally, I output the data: #output the data foreach ($group_products as $itemName => $rows) : echo '<tr>'; #echo '<td>', $element['SKU'], '</td>'; $i=0; foreach ($rows as $row) : $i++; #echo '<td>'. $row["SKU"]. '</td><td>'. $row["Label"]. '</td><td>'. $row["Value"]. '</td>'; if ($i == 1): echo '<td>'. $row["SKU"]. '</td><td>'. $row["Value"]. '</td>'; else: echo '<td>'. $row["Value"]. '</td>'; endif; #echo '<td>'. $row["Value"]. '</td>'; endforeach; echo '</tr>'; endforeach; ?> And looks like: Product code System Pack Quantity XT1CWH System 1 1 x 3m XT2CWH System 2 1 x 3m XT3CWH System 3 1 x 3m This works perfectly fine. However, some products share the same SKU and therefore it causes an issue, like the below: Product code System Pack Quantity XT1CLWH System 1 8 x 3m System 2 8 x 3m System 3 8 x 3m Is there a way I can avoid this, so if perhaps creates the new row but shows the same SKU code? Many thanks
  3. HI @Barand Is it possible to ask one more thing? In your very kind example, you have: $headings = [ 'attribute_pa_colour' => 'Colour', 'attribute_pa_description' => 'Description', 'attribute_pa_material' => 'Material', 'attribute_pa_pack-quantity' => 'Pack Quantity', 'attribute_pa_size' => 'Size', 'attribute_pa_system' => 'System', 'attribute_pa_variation' => 'Variation', 'variation_description' => 'Description', 'sku' => 'SKU', 'variation_id' => 'ID', 'price_html' => 'Price' ]; echo '<pre>', print_r($headings), '</pre>'; And if you print his out, you would see: Array ( [attribute_pa_colour] => Colour [attribute_pa_description] => Description [attribute_pa_material] => Material [attribute_pa_pack-quantity] => Pack Quantity [attribute_pa_size] => Size [attribute_pa_system] => System [attribute_pa_variation] => Variation [variation_description] => Description [sku] => SKU [variation_id] => ID [price_html] => Price ) I thought I'd try and automate this, so have the following code: $attribute_taxonomies = wc_get_attribute_taxonomies(); if ( $attribute_taxonomies ) : $taxonomyOfInterest = array(); foreach ($attribute_taxonomies as $tax=>$tax_value) : $attribute = 'attribute_pa_'.$tax_value->attribute_name; $name = 'pa_'.$tax_value->attribute_name; $label = wc_attribute_label( $name ); $taxonomyOfInterest[] = $attribute.' => '.$label.','; endforeach; endif; array_push($taxonomyOfInterest,"'variation_description' => 'Description',", "'sku' => 'SKU',", "'variation_id' => 'ID',", "'price_html' => 'Price'"); echo '<pre>', print_r($taxonomyOfInterest), '</pre>'; But when I print this out, I get: Array ( [0] => attribute_pa_colour => Colour, [1] => attribute_pa_description => Description, [2] => attribute_pa_material => Material, [3] => attribute_pa_pack-quantity => Pack Quantity, [4] => attribute_pa_size => Size, [5] => attribute_pa_system => System, [6] => attribute_pa_variation => Variation, [7] => 'variation_description' => 'Description', [8] => 'sku' => 'SKU', [9] => 'variation_id' => 'ID', [10] => 'price_html' => 'Price' ) Apologies for the terminology but how do I output this as you have it I guess without an index but arrays always need an index, right?
  4. Well that sounds jolly interesting and not something i've done before. I'll go and look into it Thanks again
  5. Hi @Barand Sorry for the delay replying. Thank you so, so much! That's absolutely bloody brilliant I think I can work out how to remove the bits and bobs I don't need to display (image_id, is_in_stock etc.) Thank you once again!
  6. Hi @Barand Mine looks like this: Array ( [attribute_pa_pack-quantity] => [dimensions] => [dimensions_html] => [image] => [image_id] => [is_in_stock] => [is_purchasable] => [is_sold_individually] => [min_qty] => [sku] => [variation_id] => [variation_is_active] => [variation_is_visible] => [weight_html] => ) I did remove a couple of items from the outset to tidy the initial array output (very first post). I'm sorry, I thought it would make life easier but wonder if I've now muddled the situation in doing so!? Otherwise it was rather lengthy: Array ( [0] => Array ( [attributes] => Array ( [attribute_pa_system] => system-1 [attribute_pa_pack-quantity] => 1-x-3m ) [availability_html] => [backorders_allowed] => [dimensions] => Array ( [length] => [width] => [height] => ) [dimensions_html] => N/A [display_price] => 0 [display_regular_price] => 0 [image] => Array ( [title] => xt1cwh_web_600 [caption] => [url] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png [alt] => [src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-600x600.png [srcset] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png 600w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-400x400.png 400w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-150x150.png 150w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-250x250.png 250w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-120x120.png 120w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-100x100.png 100w [sizes] => (max-width: 600px) 100vw, 600px [full_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png [full_src_w] => 600 [full_src_h] => 600 [gallery_thumbnail_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-100x100.png [gallery_thumbnail_src_w] => 100 [gallery_thumbnail_src_h] => 100 [thumb_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-400x400.png [thumb_src_w] => 400 [thumb_src_h] => 400 [src_w] => 600 [src_h] => 600 ) [image_id] => 719 [is_downloadable] => [is_in_stock] => 1 [is_purchasable] => 1 [is_sold_individually] => no [is_virtual] => [max_qty] => [min_qty] => 1 [price_html] => [sku] => XT1CWH [variation_description] => [variation_id] => 199 [variation_is_active] => 1 [variation_is_visible] => 1 [weight] => [weight_html] => N/A ) [1] => Array ( [attributes] => Array ( [attribute_pa_system] => system-2 [attribute_pa_pack-quantity] => 1-x-3m ) [availability_html] => [backorders_allowed] => [dimensions] => Array ( [length] => [width] => [height] => ) [dimensions_html] => N/A [display_price] => 0 [display_regular_price] => 0 [image] => Array ( [title] => xt1cwh_web_600 [caption] => [url] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png [alt] => [src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-600x600.png [srcset] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png 600w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-400x400.png 400w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-150x150.png 150w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-250x250.png 250w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-120x120.png 120w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-100x100.png 100w [sizes] => (max-width: 600px) 100vw, 600px [full_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png [full_src_w] => 600 [full_src_h] => 600 [gallery_thumbnail_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-100x100.png [gallery_thumbnail_src_w] => 100 [gallery_thumbnail_src_h] => 100 [thumb_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-400x400.png [thumb_src_w] => 400 [thumb_src_h] => 400 [src_w] => 600 [src_h] => 600 ) [image_id] => 719 [is_downloadable] => [is_in_stock] => 1 [is_purchasable] => 1 [is_sold_individually] => no [is_virtual] => [max_qty] => [min_qty] => 1 [price_html] => [sku] => XT2CWH [variation_description] => [variation_id] => 200 [variation_is_active] => 1 [variation_is_visible] => 1 [weight] => [weight_html] => N/A ) [2] => Array ( [attributes] => Array ( [attribute_pa_system] => system-3 [attribute_pa_pack-quantity] => 1-x-3m ) [availability_html] => [backorders_allowed] => [dimensions] => Array ( [length] => [width] => [height] => ) [dimensions_html] => N/A [display_price] => 0 [display_regular_price] => 0 [image] => Array ( [title] => xt1cwh_web_600 [caption] => [url] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png [alt] => [src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-600x600.png [srcset] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png 600w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-400x400.png 400w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-150x150.png 150w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-250x250.png 250w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-120x120.png 120w, https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-100x100.png 100w [sizes] => (max-width: 600px) 100vw, 600px [full_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600.png [full_src_w] => 600 [full_src_h] => 600 [gallery_thumbnail_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-100x100.png [gallery_thumbnail_src_w] => 100 [gallery_thumbnail_src_h] => 100 [thumb_src] => https://www.domain.co.uk/wp-content/uploads/2019/01/xt1cwh_web_600-400x400.png [thumb_src_w] => 400 [thumb_src_h] => 400 [src_w] => 600 [src_h] => 600 ) [image_id] => 719 [is_downloadable] => [is_in_stock] => 1 [is_purchasable] => 1 [is_sold_individually] => no [is_virtual] => [max_qty] => [min_qty] => 1 [price_html] => [sku] => XT3CWH [variation_description] => [variation_id] => 201 [variation_is_active] => 1 [variation_is_visible] => 1 [weight] => [weight_html] => N/A ) ) Apologies if this completely screws things!?
  7. What would cause: Notice: Array to string conversion in... line 93 This refers to echo "<div class='hdg'>{$headings[$h]}</div>$v<br>\n";
  8. Thank you so much @Barand for all of your help!
  9. Thanks @Barand I could do that, then use str replace to tidy it up - not ideal but a workable solution, what do you think? As I say, I could do with a pointer as to how to display the table though if possible? Sorry for asking! As a thought, the heading would always be the first attribute, so in theory would be 'attribute_pa_system'
  10. Thanks @Barand Hmm, I hadn't given that a thought! If i'm honest, i'm struggling a little as to how to output this anyway I hate arrays or they hate me, haven't decided which
  11. HI @Barand Sorry to trouble you further. If you have the array coming in with: ( [sku] => XT1ECWH [var_id] => 234 [variation] => n-a [pack_qty] => 2 ) Within your code, you currently have: $systems[$var['attributes'][0]][] = [ 'sku' => $var['sku'], 'var_id' => $var['variation_id'] ?? '', 'pack_qty' => $var['attributes'][1], 'variation' => $var['attributes'][2] ]; Which is utterly brill, however, from product to product, the attributes may differ (some have more, some have less, some are different). For example: ( [sku] => XT1ECWH [var_id] => 234 [variation] => n-a [colour] => black [pack_qty] => 2 [material] => plastic ) Is there anyway to dynamically create the internal part? $systems[$var['attributes'][0]][] = [ 'sku' => $var['sku'], 'var_id' => $var['variation_id'] ?? '', //some sort of loop here to gather the below? // 'pack_qty' => $var['attributes'][1], 'variation' => $var['attributes'][2] ]; Is that even possible?
  12. Ah it's because not every product has that specific attribute Is there a way to add a conditional check within the array?
  13. Thank you so much! I get a notice of Notice: Undefined offset: 2 which relates to this line: 'variation' => $var['attributes'][2], so now trying to work out what may be causing this Thank you again for all your help
  14. Thanks @Barand The variations (attributes) are created within a CMS. So there are various ones: System Pack Quantity Variation Colour Then each attribute has related terms, for example: System - System 1, System 2 etc. Pack Quantity - 1,2,3,10 etc. Variation: Left, Right Colour - Black, White, Grey When a product's created, you specify which Attributes you want and select the necessary variations So $variations then contains the necessary product variations As products differ with which option is first, it'd be ideal not to use a name you see, hence wondering whether you can use the [0] to denote the first attribute instead - I hope that makes sense!?
  15. Hi @Barand Thank you for your reply (as always!). May I ask, what does the double question mark mean ('var_id' => $var['variation_id'] ?? '',) Also, as the name is unknown from product to product, rather than a name like $systems[$var['attributes']['attribute_pa_system']] is it possible use a number like: $systems[$var['attributes'][0]] Thanks again
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.