Advertisement
Guest User

Untitled

a guest
Jul 26th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.04 KB | None | 0 0
  1. <?php
  2. /**
  3. * WCMp edit product template
  4. *
  5. * Used by WCMp_Products_Edit_Product->output()
  6. *
  7. * This template can be overridden by copying it to yourtheme/dc-product-vendor/vendor-dashboard/product-manager/edit-product.php.
  8. *
  9. * HOWEVER, on occasion WCMp will need to update template files and you
  10. * (the theme developer) will need to copy the new files to your theme to
  11. * maintain compatibility. We try to do this as little as possible, but it does
  12. * happen. When this occurs the version of the template file will be bumped and
  13. * the readme will list any important changes.
  14. *
  15. * @author WC Marketplace
  16. * @package WCMp/templates/vendor dashboard/product manager
  17. * @version 3.3.0
  18. */
  19. defined( 'ABSPATH' ) || exit;
  20.  
  21. global $WCMp;
  22. ?>
  23. <div class="col-md-12 add-product-wrapper">
  24. <?php do_action( 'before_wcmp_add_product_form' ); ?>
  25. <form id="wcmp-edit-product-form" class="woocommerce form-horizontal" method="post">
  26. <?php do_action( 'wcmp_add_product_form_start' ); ?>
  27. <!-- Top product highlight -->
  28. <?php
  29. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-highlights.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post, 'is_update' => $is_update ) );
  30. ?>
  31. <!-- End of Top product highlight -->
  32. <div class="product-primary-info custom-panel">
  33. <div class="right-primary-info">
  34. <div class="form-group-wrapper">
  35. <div class="form-group product-short-description">
  36. <label class="control-label col-md-12 pt-0" for="product_short_description"><?php esc_html_e( 'Product short description', 'dc-woocommerce-multi-vendor' ); ?></label>
  37. <div class="col-md-12">
  38. <?php
  39. $settings = array(
  40. 'textarea_name' => 'product_excerpt',
  41. 'textarea_rows' => get_option('default_post_edit_rows', 10),
  42. 'quicktags' => array( 'buttons' => 'em,strong,link' ),
  43. 'tinymce' => array(
  44. 'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
  45. 'theme_advanced_buttons2' => '',
  46. ),
  47. 'editor_css' => '<style>#wp-product_excerpt-editor-container .wp-editor-area{height:100px; width:100%;}</style>',
  48. );
  49. if( !apply_filters( 'wcmp_vendor_product_excerpt_richedit', true ) ) {
  50. $settings['tinymce'] = $settings['quicktags'] = $settings['media_buttons'] = false;
  51. }
  52. wp_editor( htmlspecialchars_decode( $product_object->get_short_description( 'edit' ) ), 'product_excerpt', $settings );
  53. ?>
  54. </div>
  55. </div>
  56.  
  57. <div class="form-group product-description">
  58. <label class="control-label col-md-12" for="product_description"><?php esc_attr_e( 'Product description - EN', 'dc-woocommerce-multi-vendor' ); ?></label>
  59. <div class="col-md-12">
  60. <?php
  61. $settings = array(
  62. 'textarea_name' => 'product_description',
  63. 'textarea_rows' => get_option('default_post_edit_rows', 10),
  64. 'quicktags' => array( 'buttons' => 'em,strong,link' ),
  65. 'tinymce' => array(
  66. 'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
  67. 'theme_advanced_buttons2' => '',
  68. ),
  69. 'editor_css' => '<style>#wp-product_description-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
  70. );
  71. if( !apply_filters( 'wcmp_vendor_product_description_richedit', true ) ) {
  72. $settings['tinymce'] = $settings['quicktags'] = $settings['media_buttons'] = false;
  73. }
  74.  
  75. remove_filter('the_content', 'do_shortcode', 11);
  76. wp_editor( $product_object->get_description( 'edit' ), 'product_description', $settings );
  77. ?>
  78. </div>
  79. </div>
  80.  
  81. <div class="form-group product-description">
  82. <label class="control-label col-md-12" for="product_description_fr"><?php esc_attr_e( 'Product description - FR', 'dc-woocommerce-multi-vendor' ); ?></label>
  83. <div class="col-md-12">
  84. <?php
  85. $settings = array(
  86. 'textarea_name' => 'product_description_fr',
  87. 'textarea_rows' => get_option('default_post_edit_rows', 10),
  88. 'quicktags' => array( 'buttons' => 'em,strong,link' ),
  89. 'tinymce' => array(
  90. 'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
  91. 'theme_advanced_buttons2' => '',
  92. ),
  93. 'editor_css' => '<style>#wp-product_description_fr-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
  94. );
  95. if( !apply_filters( 'wcmp_vendor_product_description_richedit', true ) ) {
  96. $settings['tinymce'] = $settings['quicktags'] = $settings['media_buttons'] = false;
  97. }
  98.  
  99. remove_filter('the_content', 'do_shortcode', 11);
  100. wp_editor( get_post_meta($product_object->id,'description_fr',true), 'product_description_fr', $settings );
  101. ?>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="left-primary-info">
  107. <div class="product-gallery-wrapper">
  108. <div class="featured-img upload_image"><?php $featured_img = $product_object->get_image_id( 'edit' ) ? $product_object->get_image_id( 'edit' ) : ''; ?>
  109. <a href="#" class="upload_image_button tips <?php echo $featured_img ? 'remove' : ''; ?>" <?php echo current_user_can( 'upload_files' ) ? '' : 'data-nocaps="true" '; ?>data-title="<?php esc_attr_e( 'Product image', 'dc-woocommerce-multi-vendor' ); ?>" data-button="<?php esc_attr_e( 'Set product image', 'dc-woocommerce-multi-vendor' ); ?>" rel="<?php echo esc_attr( $post->ID ); ?>">
  110. <div class="upload-placeholder pos-middle">
  111. <i class="wcmp-font ico-image-icon"></i>
  112. <p><?php _e( 'Click to upload Image', 'dc-woocommerce-multi-vendor' );?></p>
  113. </div>
  114. <img src="<?php echo $featured_img ? esc_url( wp_get_attachment_image_src( $featured_img, 'medium' )[0] ) : esc_url( wc_placeholder_img_src() ); ?>" />
  115. <input type="hidden" name="featured_img" class="upload_image_id" value="<?php echo esc_attr( $featured_img ); ?>" />
  116. </a>
  117. </div>
  118. <div id="product_images_container" class="custom-panel">
  119. <h3><?php _e( 'Product gallery', 'dc-woocommerce-multi-vendor' );?></h3>
  120. <ul class="product_images">
  121. <?php
  122. if ( metadata_exists( 'post', $post->ID, '_product_image_gallery' ) ) {
  123. $product_image_gallery = get_post_meta( $post->ID, '_product_image_gallery', true );
  124. } else {
  125. // Backwards compatibility.
  126. $attachment_ids = get_posts( 'post_parent=' . $post->ID . '&numberposts=-1&post_type=attachment&orderby=menu_order&order=ASC&post_mime_type=image&fields=ids&meta_key=_woocommerce_exclude_image&meta_value=0' );
  127. $attachment_ids = array_diff( $attachment_ids, array( get_post_thumbnail_id() ) );
  128. $product_image_gallery = implode( ',', $attachment_ids );
  129. }
  130.  
  131. $attachments = array_filter( explode( ',', $product_image_gallery ) );
  132. $update_meta = false;
  133. $updated_gallery_ids = array();
  134.  
  135. if ( ! empty( $attachments ) ) {
  136. foreach ( $attachments as $attachment_id ) {
  137. $attachment = wp_get_attachment_image( $attachment_id, 'thumbnail' );
  138.  
  139. // if attachment is empty skip
  140. if ( empty( $attachment ) ) {
  141. $update_meta = true;
  142. continue;
  143. }
  144.  
  145. echo '<li class="image" data-attachment_id="' . esc_attr( $attachment_id ) . '">
  146. ' . $attachment . '
  147. <ul class="actions">
  148. <li><a href="#" class="delete tips" data-tip="' . esc_attr__( 'Delete image', 'dc-woocommerce-multi-vendor' ) . '">' . __( 'Delete', 'dc-woocommerce-multi-vendor' ) . '</a></li>
  149. </ul>
  150. </li>';
  151.  
  152. // rebuild ids to be saved
  153. $updated_gallery_ids[] = $attachment_id;
  154. }
  155.  
  156. // need to update product meta to set new gallery ids
  157. if ( $update_meta ) {
  158. update_post_meta( $post->ID, '_product_image_gallery', implode( ',', $updated_gallery_ids ) );
  159. }
  160. }
  161. ?>
  162. </ul>
  163. <input type="hidden" id="product_image_gallery" name="product_image_gallery" value="<?php echo esc_attr( $product_image_gallery ); ?>" />
  164. <p class="add_product_images">
  165. <a href="#" <?php echo current_user_can( 'upload_files' ) ? '' : 'data-nocaps="true" '; ?>data-choose="<?php esc_attr_e( 'Add images to product gallery', 'dc-woocommerce-multi-vendor' ); ?>" data-update="<?php esc_attr_e( 'Add to gallery', 'dc-woocommerce-multi-vendor' ); ?>" data-delete="<?php esc_attr_e( 'Delete image', 'dc-woocommerce-multi-vendor' ); ?>" data-text="<?php esc_attr_e( 'Delete', 'dc-woocommerce-multi-vendor' ); ?>"><?php _e( 'Add product gallery images', 'dc-woocommerce-multi-vendor' ); ?></a>
  166. </p>
  167. </div>
  168. <?php do_action('wcmp_product_manager_right_panel_after', $post->ID); ?>
  169. </div>
  170. </div>
  171. </div>
  172. <div class="row">
  173. <div class="col-md-12">
  174. <div id="woocommerce-product-data" class="add-product-info-holder">
  175.  
  176. <div class="add-product-info-header row-padding">
  177. <div class="select-group">
  178. <label for="product-type"><?php esc_html_e( 'Product Type', 'dc-woocommerce-multi-vendor' ); ?></label>
  179. <select class="form-control inline-select" id="product-type" name="product-type">
  180. <?php foreach ( wcmp_get_product_types() as $value => $label ) : ?>
  181. <option value="<?php echo esc_attr( $value ); ?>" <?php echo selected( $product_object->get_type(), $value, false ); ?>><?php echo esc_html( $label ); ?></option>
  182. <?php endforeach; ?>
  183. </select>
  184. </div>
  185. <?php
  186. $product_type_options = $self->get_product_type_options();
  187. $required_types = array();
  188. foreach ( $product_type_options as $type ) {
  189. if ( isset( $type['wrapper_class'] ) ) {
  190. $classes = explode( ' ', str_replace( 'show_if_', '', $type['wrapper_class'] ) );
  191. foreach ( $classes as $class ) {
  192. $required_types[$class] = true;
  193. }
  194. }
  195. }
  196. ?>
  197. <?php if ( wcmp_is_allowed_product_type( array_keys( $required_types ) ) ) :
  198. ?>
  199. <div class="pull-right">
  200. <?php foreach ( $self->get_product_type_options() as $key => $option ) : ?>
  201. <?php
  202. if ( ! empty( $post->ID ) && metadata_exists( 'post', $post->ID, '_' . $key ) ) {
  203. $selected_value = is_callable( array( $product_object, "is_$key" ) ) ? $product_object->{"is_$key"}() : 'yes' === get_post_meta( $post->ID, '_' . $key, true );
  204. } else {
  205. $selected_value = 'yes' === ( isset( $option['default'] ) ? $option['default'] : 'no' );
  206. }
  207. ?>
  208. <label for="<?php echo esc_attr( $option['id'] ); ?>" class="<?php echo esc_attr( $option['wrapper_class'] ); ?> tips" data-tip="<?php echo esc_attr( $option['description'] ); ?>"><input type="checkbox" name="<?php echo esc_attr( $option['id'] ); ?>" id="<?php echo esc_attr( $option['id'] ); ?>" <?php echo checked( $selected_value, true, false ); ?> /> <?php echo esc_html( $option['label'] ); ?></label>
  209. <?php endforeach; ?>
  210. </div>
  211. <?php endif; ?>
  212. </div>
  213.  
  214. <!-- product Info Tab start -->
  215. <div class="product-info-tab-wrapper" role="tabpanel">
  216. <!-- Nav tabs start -->
  217. <div>
  218. <div class="tab-nav-direction-wrapper"></div>
  219. <ul class="nav nav-tabs" role="tablist" id="product_data_tabs">
  220. <?php foreach ( $self->get_product_data_tabs() as $key => $tab ) : ?>
  221. <?php if ( apply_filters( 'wcmp_afm_product_data_tabs_filter', ( ! isset( $tab['p_type'] ) || array_key_exists( $tab['p_type'], wcmp_get_product_types() ) && $WCMp->vendor_caps->vendor_can( $tab['p_type'] ) ), $key, $tab ) ) : ?>
  222. <li role="presentation" class="nav-item <?php echo esc_attr( $key ); ?>_options <?php echo esc_attr( $key ); ?>_tab <?php echo esc_attr( isset( $tab['class'] ) ? implode( ' ', (array) $tab['class'] ) : '' ); ?>">
  223. <a class="nav-link" href="#<?php echo esc_attr( $tab['target'] ); ?>" aria-controls="<?php echo $tab['target']; ?>" role="tab" data-toggle="tab"><span><?php echo esc_html( $tab['label'] ); ?></span></a>
  224. </li>
  225. <?php endif; ?>
  226. <?php endforeach; ?>
  227. <?php do_action( 'wcmp_product_write_panel_tabs', $post->ID ); ?>
  228. </ul>
  229. </div>
  230. <!-- Nav tabs End -->
  231.  
  232. <!-- Tab content start -->
  233. <div class="tab-content">
  234. <?php
  235. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-data-general.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post ) );
  236. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-data-inventory.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post ) );
  237. if ( !apply_filters('wcmp_disabled_product_shipping_tab', true) || wcmp_is_allowed_vendor_shipping() ) {
  238. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-data-shipping.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post ) );
  239. }
  240. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-data-linked-products.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post ) );
  241. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-data-attributes.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post ) );
  242. do_action( 'wcmp_after_attribute_product_tabs_content', $self, $product_object, $post );
  243. $WCMp->template->get_template( 'vendor-dashboard/product-manager/views/html-product-data-advanced.php', array( 'self' => $self, 'product_object' => $product_object, 'post' => $post ) );
  244. ?>
  245. <?php do_action( 'wcmp_product_tabs_content', $self, $product_object, $post ); ?>
  246. </div>
  247. <!-- Tab content End -->
  248. </div>
  249. <!-- product Info Tab End -->
  250. </div>
  251. </div>
  252. </div>
  253.  
  254. <div class="row">
  255. <div class="col-md-8">
  256. <?php do_action( 'wcmp_after_product_excerpt_metabox_panel', $post->ID ); ?>
  257. <?php do_action( 'wcmp_afm_after_product_excerpt_metabox_panel', $post->ID ); ?>
  258.  
  259. <?php
  260. do_action( 'wcmp_before_product_note_metabox_panel', $post->ID );
  261. $vendor = get_wcmp_vendor(get_current_user_id() );
  262. $notes = WCMp_Product::get_product_note($post->ID);
  263. ?>
  264. <?php if($post->post_status == 'pending') { ?>
  265. <div class="panel panel-default pannel-outer-heading order-action">
  266. <div class="panel-heading d-flex">
  267. <?php esc_html_e( 'Rejection Note', 'dc-woocommerce-multi-vendor' ); ?>
  268. </div>
  269. <div class="panel-body panel-content-padding form-group-wrapper">
  270. <ul class="order_notes list-group mb-0">
  271. <li class="list-group-item list-group-item-action flex-column align-items-start add_note">
  272. <?php if (apply_filters('is_vendor_can_add_product_notes', true, $vendor->id)) : ?>
  273. <!-- <form method="post" name="add_product_comment"> -->
  274. <?php wp_nonce_field('dc-vendor-add-product-comment', 'vendor_add_product_nonce'); ?>
  275. <h3><?php _e( 'Add note', 'dc-woocommerce-multi-vendor' ); ?> <span class="img_tip" data-desc="<?php echo __( 'Add a note for your reference, or add a customer note (the user will be notified).', 'dc-woocommerce-multi-vendor' ); ?>"></span></h3>
  276. <div class="form-group">
  277. <textarea placeholder="<?php _e('Enter text ...', 'dc-woocommerce-multi-vendor'); ?>" class="form-control" name="product_comment_text"></textarea>
  278. </div>
  279. <div class="form-group">
  280. <input class="btn btn-default wcmp-add-order-note" type="submit" name="wcmp_submit_product_comment" value="<?php _e('Submit', 'dc-woocommerce-multi-vendor'); ?>">
  281. </div>
  282. <input type="hidden" name="product_id" value="<?php echo $post->ID; ?>">
  283. <input type="hidden" name="current_user_id" value="<?php echo $vendor->id; ?>">
  284. <!-- </form> -->
  285. <?php endif; ?>
  286. </li>
  287. <li class="list-group-item list-group-item-action flex-column align-items-start"><div class="form-group"><h3><?php esc_html_e( 'Communication Log', 'dc-woocommerce-multi-vendor' ); ?></h3></div></li>
  288. <?php
  289. if ($notes) {
  290. foreach ($notes as $note) {
  291. $author = get_comment_meta( $note->comment_ID, '_author_id', true );
  292. $Seller = is_user_wcmp_vendor($author) ? "(Seller)" : '';
  293. ?>
  294. <li class="list-group-item list-group-item-action flex-column align-items-start order-notes">
  295. <p class="order-note"><span><?php echo wptexturize( wp_kses_post( $note->comment_content ) ); ?></span></p>
  296. <p><?php echo esc_html($note->comment_author); ?><?php echo $Seller; ?> - <?php echo esc_html( date_i18n(wc_date_format() . ' ' . wc_time_format(), strtotime($note->comment_date) ) ); ?></p>
  297. </li>
  298. <?php
  299. }
  300. }else{
  301. echo '<li class="list-group-item list-group-item-action flex-column align-items-start order-notes">' . __( 'There are no notes yet.', 'dc-woocommerce-multi-vendor' ) . '</li>';
  302. }
  303. ?>
  304. </ul>
  305. </div>
  306. </div>
  307. <?php do_action( 'wcmp_after_product_note_metabox_panel', $post->ID ); ?>
  308. <?php } ?>
  309. </div>
  310. <div class="col-md-4">
  311. <?php if( ( get_wcmp_vendor_settings('is_disable_marketplace_plisting', 'general') == 'Enable' ) ) :
  312. $product_categories = wcmp_get_product_terms_HTML( 'product_cat', $post->ID, apply_filters( 'wcmp_vendor_can_add_product_category', false, get_current_user_id() ) ); ?>
  313. <?php if ( $product_categories ) : ?>
  314. <div class="panel panel-default pannel-outer-heading">
  315. <div class="panel-heading d-flex">
  316. <h3 class="pull-left"><?php esc_html_e( 'Product categories', 'dc-woocommerce-multi-vendor' ); ?></h3>
  317. </div>
  318. <div class="panel-body panel-content-padding form-group-wrapper">
  319. <?php
  320. echo $product_categories;
  321. ?>
  322. </div>
  323. </div>
  324. <?php endif;
  325. endif; ?>
  326. <?php
  327. $custom_taxonomies = get_object_taxonomies( 'product', 'objects' );
  328. if( $custom_taxonomies ){
  329. foreach ( $custom_taxonomies as $taxonomy ) {
  330. if ( in_array( $taxonomy->name, array( 'product_cat', 'product_tag' ) ) ) continue;
  331. if ( $taxonomy->public && $taxonomy->show_ui && $taxonomy->meta_box_cb ) { ?>
  332. <div class="panel panel-default pannel-outer-heading">
  333. <div class="panel-heading d-flex">
  334. <h3 class="pull-left"><?php echo $taxonomy->label; ?></h3>
  335. </div>
  336. <div class="panel-body panel-content-padding form-group-wrapper">
  337. <div class="form-group">
  338. <div class="col-md-12">
  339. <?php
  340. echo wcmp_get_product_terms_HTML( $taxonomy->name, $post->ID, apply_filters( 'wcmp_vendor_can_add_'.$taxonomy->name, false, get_current_user_id() ) );
  341. ?>
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. <?php }
  347. }
  348. }
  349. ?>
  350. <?php do_action( 'after_wcmp_product_tags_metabox_panel', $post->ID ); ?>
  351. </div>
  352. </div>
  353. <?php if ( ! empty( wcmp_get_product_types() ) ) : ?>
  354. <div class="wcmp-action-container">
  355. <?php
  356. $primary_action = __( 'Submit', 'dc-woocommerce-multi-vendor' ); //default value
  357. if ( current_vendor_can( 'publish_products' ) ) {
  358. if ( ! empty( $product_object->get_id() ) && get_post_status( $product_object->get_id() ) === 'publish' ) {
  359. $primary_action = __( 'Update', 'dc-woocommerce-multi-vendor' );
  360. } else {
  361. $primary_action = __( 'Publish', 'dc-woocommerce-multi-vendor' );
  362. }
  363. }
  364. ?>
  365. <input type="submit" class="btn btn-default" name="submit-data" value="<?php echo esc_attr( $primary_action ); ?>" id="wcmp_afm_product_submit" />
  366. <input type="submit" class="btn btn-default" name="draft-data" value="<?php esc_attr_e( 'Draft', 'dc-woocommerce-multi-vendor' ); ?>" id="wcmp_afm_product_draft" />
  367. <input type="hidden" name="status" value="<?php echo esc_attr( get_post_status( $post ) ); ?>">
  368. <?php wp_nonce_field( 'wcmp-product', 'wcmp_product_nonce' ); ?>
  369. </div>
  370. <?php endif; ?>
  371. <?php do_action( 'wcmp_add_product_form_end' ); ?>
  372. </form>
  373. <?php do_action( 'after_wcmp_add_product_form' ); ?>
  374. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement