bongzilla

Untitled

Jul 27th, 2021
35
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shortcode_template($data) {
  2. $id = $data["id"];
  3. $name = $data["name"];
  4. $price = $data["price"];
  5. $url = $data["url"];
  6.  
  7. $template = <<<EOF
  8. <div class="b-card-mini">
  9. <div class="h-wrap h-wrap_flex-h h-wrap_card">
  10. <div class="b-card-mini___add-to-card w-form">
  11. <form data-name="add_to_cart" id="add_to_cart_{$id}" data-action="add_to_cart" name="add_to_cart" action="/index.php" data-product-id="{$id}" data-product_id="{$id}">
  12. <div class="h-text h-text_mg-bottom_20 h-text_flex"><a href="{$url}" class="b-card-mini__title-link">{$name}</a>
  13. <div class="b-card-mini__wrap-price">
  14. <div class="b-text-price slider__b-text-price" data-content="product_price" style="display:block;">
  15. {$price}&nbsp;₽ </div>
  16. <div class="b-text-price slider__b-text-price_sale" data-content="product_price_sale" style="display:none;">
  17. </div>
  18. <div class="b-text-price slider__b-text-price_regular" data-content="product_price_regular" style="display:none;">
  19. </div>
  20. </div>
  21. </div>
  22. <div class="h-wrap h-wrap_flex-h h-wrap_card">
  23. <div class="h-wrap h-wrap_flex-horizontal">
  24. <div class="h-button">
  25. <input type="submit" value="Добавить в смету" data-wait="Please wait..." class="b-button v-8__button w-button"></div>
  26. <div class="h-wrap h-wrap_padding-left_20 w-clearfix"><a href="#" class="card-block__minus poligon_white w-button" data-action="product_qty_minus"></a>
  27. <input type="text" class="b-form__input w-input" maxlength="256" name="qty" data-name="qty" id="qty{$id}" data-action="product_qty" value="1" data-qty-min="1" data-qty-max="0" data-qty-step="1"><a href="#" class="card-block__plus poligon_white w-button" data-action="product_qty_plus"></a></div>
  28. </div>
  29. <div class="h-wrap h-wrap_padding-left_20 _1"><a href="{$url}" target="_blank" class="b-link b-link_align_right">Подробнее <br>в новой вкладке</a></div>
  30. </div>
  31. </form>
  32. <div class="success-message w-form-done">
  33. <div class="text-block-23">Услуга добавленна</div>
  34. </div>
  35. <div class="w-form-fail">
  36. <div>Oops! Что то пошло не так=(</div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. EOF;
  42.  
  43. return $template;
  44. }
  45.  
  46. add_shortcode("product_upsell", "product_upsell_func");
  47.  
  48. function product_upsell_func( $atts, $content, $tag ){
  49. $post_id = $atts["id"];
  50. $product = wc_get_product($post_id);
  51. $name = $product->name;
  52. $price = $product->price;
  53. $url = $product->get_permalink();
  54.  
  55. $data = array(
  56. "id" => $post_id,
  57. "name" => $name,
  58. "price" => $price,
  59. "url" => $url
  60. );
  61.  
  62. echo shortcode_template($data);
  63. }
  64.  
RAW Paste Data