Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shortcode_template($data) {
- $id = $data["id"];
- $name = $data["name"];
- $price = $data["price"];
- $url = $data["url"];
- $template = <<<EOF
- <div class="b-card-mini">
- <div class="h-wrap h-wrap_flex-h h-wrap_card">
- <div class="b-card-mini___add-to-card w-form">
- <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}">
- <div class="h-text h-text_mg-bottom_20 h-text_flex"><a href="{$url}" class="b-card-mini__title-link">{$name}</a>
- <div class="b-card-mini__wrap-price">
- <div class="b-text-price slider__b-text-price" data-content="product_price" style="display:block;">
- {$price} ₽ </div>
- <div class="b-text-price slider__b-text-price_sale" data-content="product_price_sale" style="display:none;">
- </div>
- <div class="b-text-price slider__b-text-price_regular" data-content="product_price_regular" style="display:none;">
- </div>
- </div>
- </div>
- <div class="h-wrap h-wrap_flex-h h-wrap_card">
- <div class="h-wrap h-wrap_flex-horizontal">
- <div class="h-button">
- <input type="submit" value="Добавить в смету" data-wait="Please wait..." class="b-button v-8__button w-button"></div>
- <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>
- <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>
- </div>
- <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>
- </div>
- </form>
- <div class="success-message w-form-done">
- <div class="text-block-23">Услуга добавленна</div>
- </div>
- <div class="w-form-fail">
- <div>Oops! Что то пошло не так=(</div>
- </div>
- </div>
- </div>
- </div>
- EOF;
- return $template;
- }
- add_shortcode("product_upsell", "product_upsell_func");
- function product_upsell_func( $atts, $content, $tag ){
- $post_id = $atts["id"];
- $product = wc_get_product($post_id);
- $name = $product->name;
- $price = $product->price;
- $url = $product->get_permalink();
- $data = array(
- "id" => $post_id,
- "name" => $name,
- "price" => $price,
- "url" => $url
- );
- echo shortcode_template($data);
- }
Advertisement
Add Comment
Please, Sign In to add comment